Output
The mode option in config/sitemapamic.php controls how your sitemap is split into files.
1'mode' => 'automatic',
Mode | Description |
|---|---|
| A |
| Everything in one |
Any other value throws an InvalidArgumentException when the sitemap is built.
Automatic mode
sitemap.xml is a sitemap index that lists one or more files for each source of URLs:
Source | Filename |
|---|---|
A Collection's entries |
|
A Collection's term pages for a Taxonomy |
|
A Taxonomy's term pages |
|
|
For example, a site with pages and blog Collections, where blog has tags attached, would have:
1sitemap.xml2sitemap-collection-blog-1.xml3sitemap-collection-blog-taxonomy-tags-1.xml4sitemap-collection-pages-1.xml5sitemap-taxonomy-tags-1.xml
Files are listed in a stable order: Collections by handle, each followed by its term pages, then Taxonomies by handle, then dynamic routes. A source with no URLs gets no file.
Separate files make it easier to see each section's indexing in tools like Google Search Console.
Single mode
sitemap.xml is an ordinary sitemap containing every URL, with no index:
1'mode' => 'single',
If it outgrows one file, it is split into sitemap-all-1.xml, sitemap-all-2.xml and so on, and sitemap.xml becomes an index listing them. You don't need to change anything when this happens: search engines follow the index.
File size limits
The sitemap protocol allows up to 50,000 URLs and 50MB per file. In either mode, a file that would go over either limit is split into numbered files: sitemap-collection-blog-1.xml, sitemap-collection-blog-2.xml, and so on.
Search engines only need sitemap.xml. Submit that, and they will find the rest.
Sitemap URLs
Each site's sitemap is served at the root of that site's URL:
Site URL | Sitemap |
|---|---|
|
|
|
|
|
|
A site with a relative URL, such as /fr, uses your APP_URL as its domain.
To get a sitemap's URL in your code, such as for your robots.txt, use the facade:
1use MityDigital\Sitemapamic\Facades\Sitemapamic;2 3Sitemapamic::url(); // the current site's sitemap.xml4Sitemapamic::url('fr'); // the "fr" site's sitemap.xml5Sitemapamic::url('fr', 'sitemap-dynamic-1.xml'); // one of its files
Empty sitemaps
A site with nothing to list has no sitemap: sitemap.xml returns a 404. It appears as soon as there is something to list.
Changing the mode
Changing mode takes effect on the next request. The cache notices the configuration has changed and rebuilds, so you don't need to clear it.
If you have already submitted individual files to a search engine, such as sitemap-collection-blog-1.xml, remember that changing the mode changes the filenames. Submitting just sitemap.xml avoids this.