spatie/laravel-sitemap
Generate XML sitemaps for Laravel by crawling your site or building them manually. Add extra URLs, set last-modified dates, and include models via a simple interface. Write sitemaps to disk with a fluent, developer-friendly API.
Multilingual sites may have several alternate versions of the same page (one per language). You can add alternates using the addAlternate method, which takes an alternate URL and the locale it belongs to.
use Spatie\Sitemap\SitemapGenerator;
use Spatie\Sitemap\Tags\Url;
SitemapGenerator::create('https://example.com')
->getSitemap()
->add(
Url::create('/extra-page')
->addAlternate('/extra-pagina', 'nl')
->addAlternate('/page-supplementaire', 'fr')
)
->writeToFile($sitemapPath);
How can I help you explore Laravel packages today?