Remove html link from sitemap in laravel

129 views Asked by At

I try to remove html links from sitemap xml in laravel i use Spatie SitemapGenerator and this is corn job it's run every weekly, i do this way but it's not working

public function handle()
{
    $url = "https://www.example.com";
    $sitemapGenerator = SitemapGenerator::create($url);
    $sitemapGenerator->shouldCrawl(function ($url) {
        return !str_ends_with($url, '.html');
    });
    
    $sitemapGenerator->writeToFile(public_path('sitemap.xml'));

    $this->info('Sitemap generated successfully.');

    return 0;
}

i wand remove these kind of links from sitemap

<url>
<loc>https://www.example.com/resources/press-release/-marketing-professional-of-the-year/index.html</loc>
<lastmod>2023-07-13T04:30:52+00:00</lastmod>
<changefreq>daily</changefreq>
<priority>0.8</priority>
</url>

These kind of many links are in my site how to remove this?

0

There are 0 answers