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.
SitemapGenerator) and manual URL injection (via Sitemap/Url), enabling granular control over sitemap content.Sitemapable interface allows seamless integration with Eloquent models, reducing boilerplate for dynamic content (e.g., blog posts, products).spatie/browsershot), accommodating complex SPAs or client-side-rendered content.spatie/laravel-sitemap (MIT).spatie/browsershot (for JS execution), spatie/crawler (under the hood).laravel-seo or spatie/laravel-newsletter for unified metadata management.setConcurrency()).setMaximumCrawlCount()).auth routes by default; requires custom shouldCrawl() logic.hasCrawled() filter).sitemap.xml and sitemap-index.xml (use SitemapIndex class for automation).SitemapGenerator in unit tests using Sitemap::fake() (if available) or dependency injection.public_path(), S3, etc.) and how will they be invalidated on updates?writeToDisk()).Model::saved() or Model::deleted() to update sitemaps dynamically.Http::fake() for crawler mocks).spatie/laravel-seo (for meta tags), spatie/laravel-newsletter (for content routing).Sitemap::create()->add(...)) for critical routes (e.g., /blog, /products).lastmod timestamps).SitemapGenerator for non-authenticated routes.shouldCrawl() to exclude dynamic or sensitive endpoints.Sitemapable on key models (e.g., Post, Product) to auto-generate URLs.SitemapGenerator::create()->getSitemap()->add($model).sitemap:generate) or Laravel Forge/Envoyer hooks.composer.json for exact version constraints.cURL, DOM, and MBString (standard in Laravel).spatie/browsershot).spatie/crawler).| Phase | Task | Dependencies |
|---|---|---|
| Discovery | Audit existing sitemaps, identify gaps. | SEO team input. |
| Setup | Install package, publish config, configure sitemap.php. |
DevOps for Chrome setup (if needed). |
| Validation | Generate test sitemap, validate against Google Search Console. | Existing sitemap for comparison. |
| Integration | Implement Sitemapable on models, add crawler filters. |
Model definitions. |
| Automation | Schedule generation, set up monitoring. | CI/CD pipeline. |
| Optimization | Tune concurrency/depth, add JS crawling if needed. | Performance benchmarks. |
config/sitemap.php (e.g., execute_javascript, chrome_binary_path).SitemapGenerator::create()->setConcurrency(5)) for environment-specific settings.spatie/crawler and spatie/browsershot for updates.shouldCrawl() logic, network timeouts, or blocked robots.txt.hasCrawled() filters or model toSitemapTag() implementations.execute_javascript is configured.Spatie\Crawler\Crawler::debug() for verbose output.Sitemap::fake() (if available) or manually inspect generated XML.depth() or setMaximumCrawlCount().setConcurrency() based on server resources (start with 5–10).How can I help you explore Laravel packages today?