-1

I'm using spatie/sitemap

this is what i do to inform me that sitemap is created

Route::get('sitemap', function(){

SitemapGenerator::create('http://localhost/')->writeToFile('sitemap.xml');

return "sitemap created"; });

and this is my APP_URL

APP_URL=http://localhost

i have 2 routes that could show up when i do sitemap:generate, but only this URL that contains in

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
    <url>
        <loc>http://localhost/</loc>
    
    
        <lastmod>2019-03-07T11:54:02+00:00</lastmod>
    
        <changefreq>daily</changefreq>
    
        <priority>0.8</priority>
    </url>
</urlset>

is there anything wrong? i am using windows 10 for your information

apokryfos
  • 38,771
  • 9
  • 70
  • 114
Dava Eranda
  • 29
  • 1
  • 1
  • 8
  • You could try to have a virtual host and not run the app on `http://localhost`. – thefallen Mar 07 '19 at 12:26
  • Is the route that is not showing up in the sitemap referenced anywhere in your view at `http://localhost/`? – D Malan Mar 07 '19 at 12:34
  • @thefallen i try that using laravel valet, unfortunately its only for Mac. what should i do to try virtual host? – Dava Eranda Mar 07 '19 at 12:37
  • @DelenaMalan there is two route in my web.php and it is not showing up – Dava Eranda Mar 07 '19 at 12:37
  • If you have WAMP/XAMP you will have Apache or Nginx where you should add your application. Unfortunately I'm on linux and I can't point you to where the folder for this is, but you should definitely have existing examples that come installed as default, – thefallen Mar 07 '19 at 12:41
  • @thefallen i'll try to do that, thank you – Dava Eranda Mar 07 '19 at 12:42
  • @DavaEranda your routes need to be referenced in your views and not just be present in your `routes/web.php` file. The package works by **crawling** your site. For example, your view at `http://localhost` should include a link to your second route, e.g. `Link`. – D Malan Mar 07 '19 at 12:43
  • 1
    @thefallen you're right, i try to do virtual host and it works, thanks. – Dava Eranda Mar 14 '19 at 04:17

1 Answers1

0

So it works when you're not using localhost:8000 or 127.0.0.1:8000. you should change your web address using laravel valet for MAC or change your hosts for Windows

Dava Eranda
  • 29
  • 1
  • 1
  • 8