Mity Docs Mity Docs for Mity Digital
Sitemapamic Documentation

Output

The mode option in config/sitemapamic.php controls how your sitemap is split into files.

1'mode' => 'automatic',

Mode

Description

automatic

A sitemap.xml index, with a separate file for each Collection, Taxonomy and your dynamic routes. This is the default.

single

Everything in one sitemap.xml file, which may suit smaller sites.

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

sitemap-collection-{collection}-1.xml

A Collection's term pages for a Taxonomy

sitemap-collection-{collection}-taxonomy-{taxonomy}-1.xml

A Taxonomy's term pages

sitemap-taxonomy-{taxonomy}-1.xml

Dynamic Routes

sitemap-dynamic-1.xml

For example, a site with pages and blog Collections, where blog has tags attached, would have:

1sitemap.xml
2sitemap-collection-blog-1.xml
3sitemap-collection-blog-taxonomy-tags-1.xml
4sitemap-collection-pages-1.xml
5sitemap-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

https://example.com

https://example.com/sitemap.xml

https://example.com/fr

https://example.com/fr/sitemap.xml

https://example.fr

https://example.fr/sitemap.xml

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.xml
4Sitemapamic::url('fr'); // the "fr" site's sitemap.xml
5Sitemapamic::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.