@johnbraun
Thanks for reply my thread.
It's seem like manual to create Url. I just test it. But it's just create simple like:
<?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/e-commerce/routes/web</loc>
<lastmod>2020-07-19T00:00:00+00:00</lastmod>
<changefreq>yearly</changefreq>
<priority>0.1</priority>
</url>
</urlset>
I want this can generate only route of web.
I just see a package about config CustomCrawlProfile and i'm doing like this:
<?php
namespace Spatie\Sitemap\Crawler;
use Spatie\Crawler\CrawlProfile;
use Psr\Http\Message\UriInterface;
class CustomCrawlProfile extends CrawlProfile
{
public function shouldCrawl(UriInterface $url): bool
{
if ($url->getHost() !== 'localhost') {
return false;
}
return $url->getPath() === '/';
}
}
In GenerateSitemap:
public function handle()
{
// modify this to your own needs
SitemapGenerator::create(config('app.url'))
->shouldCrawl(function (UriInterface $url) {
return strpos($url->getPath(), '/web');
})
->writeToFile(public_path('sitemap.xml'));
}
In .env:
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:9LMUlL/+/PnLdjbnW4SHEMpEsfN0chH7HIyE30HR2PQ=
APP_DEBUG=true
APP_URL=http://localhost/e-commerce/routes/
LOG_CHANNEL=stack
And it's just show about:
<?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>