spatie/laravel-sitemap
Generate sitemaps for your Laravel site with ease. Crawl your entire site automatically or build sitemaps manually, add URLs with metadata like last modification dates, and split large crawls into multiple sitemap files.
maxTagsPerSitemap splitting logic.writeToFile(fn (Url $url) => ...) closure lets us route URLs into separate sitemap files by section (e.g. /blog vs. the rest), and returning null excludes a URL entirely. That's a direct product lever: we can decide per section whether it gets indexed, and then read coverage per section in Search Console instead of guessing from one monolithic file.Sitemapable (toSitemapTag()) ties sitemap entries to Eloquent models, so publishing, unpublishing, or renaming a post updates the sitemap without a separate content-ops step. This removes a recurring class of "the sitemap is stale" bugs that typically fall to whoever owns marketing ops.SitemapGenerator::create('https://example.com')) gets us coverage in an afternoon with no route inventory; manual Sitemap::create()->add(Url::create(...)) gives us precision when we need it; the hybrid (getSitemap()->add(...)) covers "crawl the long tail, hand-curate the money pages."setLastModificationDate on pages where freshness signals matter.Adopt when most of the following hold:
<a href> links.Look elsewhere when:
Sitemap directly from a query (or a queued job per shard) is the better architecture — the package still helps, but the crawl mode does not.To executives: This is a small, free, MIT-licensed dependency from a well-known Laravel vendor that turns sitemap generation from a manual, error-prone chore into a scheduled, code-reviewed job. It costs one composer require and a few hours of integration, and it makes search visibility measurable — we can report index coverage per site section in Search Console instead of a single undifferentiated number. No vendor contract, no lock-in, no per-URL pricing.
To engineering: Narrow surface area, one dependency, PHP 8+ only, actively released (latest 2026-06-24) with passing tests, PHPStan, and documented changelog. Supports Laravel 11, model-driven entries via the Sitemapable contract, crawl-plus-manual hybrid generation, multi-file output with a generated index, maxTagsPerSitemap chunking, and image/video/Google News tags. Integration is typically a scheduled command writing to public/, or writeToDisk() if we'd rather use the storage disk.
The honest caveats to state up front: crawling our own production site from production has a real cost — schedule it off-peak, cap the crawl, and exclude admin/account/search-filter URLs with filters or null returns. Crawler-version coupling is the main upgrade friction. And crawling is a poor fit if any key surface is client-rendered; that's a rendering problem this package cannot solve for us.
How can I help you explore Laravel packages today?