I am using spatie to generate sitemap.xml. It is working properly as it is expected. But as per some requirement I would like to not include any image url in sitemap.xml.
This is my code -
public function sitemap(){
$link = Website::where('adminId', Auth::user()->id)->value('link');
$path = public_path('uploads/'.Auth::user()->id.'/sitemap.xml');
if (file_exists($path)) {
File::delete($path);
fopen($path, 'w');
} else {
fopen($path, 'w');
}
SitemapGenerator::create($link)->writeToFile($path);
return response()->json('success');
}
Currently my sitemap.xml
something looks like this with image links -
<url>
<loc>http://www.example.com/uploads/3/page/anahera/1591769129-4412.jpeg</loc>
<lastmod>2020-06-23T11:22:59+12:00</lastmod>
<changefreq>daily</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>http://www.example.com/uploads/3/page/anahera/1591769136-7646.jpeg</loc>
<lastmod>2020-06-23T11:22:59+12:00</lastmod>
<changefreq>daily</changefreq>
<priority>0.8</priority>
</url>
This there any way to remove those image links from sitemap.xml?
Appreciate for help.