I am developing a Laravel application. Now, I am trying to implement the sitemap for my website using this package, https://github.com/spatie/laravel-sitemap. But when I generate sitemap.xml, no paths are included in the file.
I installed the package running the Composer command
composer require spatie/laravel-sitemap
Then I published the Composer.
php artisan vendor:publish --provider="Spatie\Sitemap\SitemapServiceProvider" --tag=config
In the routes/web.php, I added this.
Route::get('sitemap', function () {
SitemapGenerator::create('http://app.localhost/')->writeToFile('sitemap.xml');
return "Sitemap generated".
});
When I run the code and sitemap.xml is generated. When I opened the sitemap.xml, that is all I found in it.
<?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">
</urlset>
I have many routes in the web.php. What is wrong and how can fix it?