nhayder
129
0
Laravel

spatie/laravel-sitemap not crawling the site (sitemap.xml is empty)

Posted 2 months ago by nhayder

Hi, i'm using spatie/laravel-sitemap https://github.com/spatie/laravel-sitemap to auto-generate sitemap for my app.

as per the documentation i made a command to generate the the site map like this

<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Spatie\Sitemap\SitemapGenerator;

class GenerateSitemap extends Command
{
    /**
     * The console command name.
     *
     * @var string
     */
    protected $signature = 'sitemap:generate';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Generate the sitemap.';

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        // modify this to your own needs
        SitemapGenerator::create(config('app.url'))

            ->writeToFile(public_path('sitemap.xml'));
            
    }
}

The site map is file is created but its empty so basically it looks like the package is not crawling the app as it should do,

has anybody used this package, How to fix this issue ???

Please sign in or create an account to participate in this conversation.