Sitemap index files
A sitemap index is an XML file that lists other sitemaps instead of pages. It is required once a site passes 50,000 URLs or 50 MB in one sitemap, and it is useful well before that for splitting a site by section.
Type: ReferenceVersionSitemaps 0.9On this page
A single sitemap may list at most 50,000 URLs and may be no larger than 50 MB (52,428,800 bytes) uncompressed. A site that needs more must use several sitemaps, and the Sitemaps protocol asks that they be listed in a sitemap index file. The index has the same shape as a sitemap, with sitemapindex in place of urlset and sitemap entries in place of url entries. Crawlers are then given one address, and they find the rest from it.
Elements
| Element | Required | Contents |
|---|---|---|
| sitemapindex | Yes | The root element, with the namespace http://www.sitemaps.org/schemas/sitemap/0.9. Encloses every sitemap entry. |
| sitemap | Yes, one per child file | Describes one sitemap. |
| loc | Yes | The full URL of the child sitemap. sitemaps.org also allows an RSS or Atom feed or a plain text list of URLs here. |
| lastmod | No | When the child sitemap file was last modified, in W3C Datetime format: a date such as 2026-12-03, or a date and time with a time zone. |
lastmod in an index describes the sitemap file, not the pages in it. The protocol explains the purpose: a crawler can fetch only the sitemaps that changed since its last visit, which saves work on large sites. A generator should therefore set it to the time the child file's content last changed, not to the time the index was rebuilt.
A complete index
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>https://www.example.com/sitemap-pages.xml</loc>
<lastmod>2026-11-28</lastmod>
</sitemap>
<sitemap>
<loc>https://www.example.com/sitemap-docs-1.xml.gz</loc>
<lastmod>2026-12-03T09:15:00+00:00</lastmod>
</sitemap>
<sitemap>
<loc>https://www.example.com/sitemap-docs-2.xml.gz</loc>
<lastmod>2026-10-14</lastmod>
</sitemap>
<sitemap>
<loc>https://www.example.com/sitemap-blog.xml</loc>
</sitemap>
</sitemapindex>The file must be UTF-8, and every URL must be entity-escaped like any other XML value, so an ampersand in a query string is written as &. The structure of the child files themselves is described in Sitemap XML format.
Limits
| Limit | Value | Source |
|---|---|---|
| Sitemaps listed in one index | 50,000 | sitemaps.org; Google |
| Size of one index file | 50 MB (52,428,800 bytes), uncompressed | sitemaps.org |
| Index files per site | No limit in the protocol: a site may have more than one index | sitemaps.org |
| Index files submitted per site in Search Console | 500 | |
| Indexes listing other indexes | Not supported |
Google's documentation is explicit that an index can only list individual sitemaps: an index that references another index is not supported. Nothing in the protocol offers a third level, so a site that would need one should list several indexes in robots.txt or submit them separately.
Compression
Both sitemaps and index files may be compressed with gzip, conventionally with the extension .xml.gz. The size limits apply to the uncompressed file, so compression saves bandwidth but does not let a file hold more.
Where the files may live
An index can only list sitemaps on the same site as the index. sitemaps.org gives the example that an index at www.yoursite.com cannot point to sitemaps on another domain or even on another subdomain of the same domain. Google adds that the child sitemaps must be in the same directory as the index or below it, and waives the same-site rule when cross-site submission has been set up through robots.txt, as described in where site files live: the root path and /.well-known/.
Each child sitemap is still bound by its own location rule: a sitemap stored in /docs/ may only list URLs under /docs/. The simplest arrangement is therefore an index at the root, at /sitemap.xml or /sitemap_index.xml, with the child files at the root beside it, as in the example above. Child files can go in a subdirectory only if every URL they list lies under that directory. Crawlers need only the index address, whether from robots.txt or a search engine's submission form; see how crawlers find a sitemap.
User-agent: *
Disallow: /search
Sitemap: https://www.example.com/sitemap.xmlSplitting a site by section
An index is worth having before any limit is reached. One sitemap per section keeps each file's lastmod meaningful, makes a stuck section easy to spot in Search Console's sitemap report, and lets a section be rebuilt without touching the others. A documentation site might divide its URLs like this:
| Child sitemap | URLs it lists | Changes when |
|---|---|---|
| sitemap-pages.xml | Home page, section landing pages, about and policy pages | Rarely |
| sitemap-docs-1.xml.gz, sitemap-docs-2.xml.gz | Documentation pages, 50,000 per file | Whenever a page is revised |
| sitemap-blog.xml | Blog posts | When a post is published or corrected |
The sketch below, in Python, writes one or more sitemaps per section and an index that lists them, taking each child's lastmod from the newest page it contains. It splits on the 50,000 URL limit; a site with unusually long URLs should also check the 50 MB limit.
from xml.sax.saxutils import escape
BASE = "https://www.example.com"
LIMIT = 50_000
NS = "http://www.sitemaps.org/schemas/sitemap/0.9"
# section name -> list of (absolute URL, ISO 8601 date of last change)
sections = {
"pages": [(BASE + "/", "2026-11-28"), (BASE + "/about", "2026-06-02")],
"docs": [(BASE + "/docs/sitemaps", "2026-12-03")],
}
children = []
for name, urls in sections.items():
for n in range(0, len(urls), LIMIT):
chunk = urls[n:n + LIMIT]
filename = f"sitemap-{name}-{n // LIMIT + 1}.xml"
with open(filename, "w", encoding="utf-8") as f:
f.write(f'<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="{NS}">\n')
for loc, lastmod in chunk:
f.write(f" <url><loc>{escape(loc)}</loc><lastmod>{lastmod}</lastmod></url>\n")
f.write("</urlset>\n")
children.append((f"{BASE}/{filename}", max(d for _, d in chunk)))
with open("sitemap.xml", "w", encoding="utf-8") as f:
f.write(f'<?xml version="1.0" encoding="UTF-8"?>\n<sitemapindex xmlns="{NS}">\n')
for loc, lastmod in children:
f.write(f" <sitemap><loc>{escape(loc)}</loc><lastmod>{lastmod}</lastmod></sitemap>\n")
f.write("</sitemapindex>\n")The script writes every file to the root, so each child sitemap may list URLs from anywhere on the host. The max() call works because all dates share one ISO 8601 format; mixed date and date-time values would need to be parsed first.
Validating
sitemaps.org publishes an XML Schema for index files at http://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd, separate from the schema for sitemaps. Common faults that a schema check or Search Console will report are a urlset root in a file submitted as an index, relative URLs in loc, unescaped ampersands, and child sitemaps that return a redirect or an error instead of 200.
See also
- Sitemap XML formatEvery element of the Sitemaps 0.9 XML format, with the size limits, encoding and escaping rules, which fields Google uses, and the RSS, Atom and text alternatives.
- How crawlers find a sitemapA sitemap only helps once a crawler knows where it is. The Sitemap line in robots.txt, submission in Google Search Console and Bing Webmaster Tools, the retired ping endpoint, and IndexNow for announcing changed URLs.
- Language alternates in sitemapsA sitemap can tell search engines that pages are translations or regional versions of each other, using xhtml:link elements with hreflang values inside each url entry. Every version lists every version, itself included.
- Where site files live: the root path and /.well-known/Clients find machine-readable site files at fixed addresses: some at the root of each host, some under the /.well-known/ prefix of RFC 8615, and some inside every page. Where a file sits also decides which URLs it can speak for.
- Serving site files: media types, encoding and status codesWhich Content-Type each machine-readable file should be served with, why UTF-8 matters, and how crawlers react to redirects, client errors and server errors when they request robots.txt.
References
- sitemaps.org. Sitemaps XML format: Using Sitemap index files. sitemaps.org
- sitemaps.org. Sitemaps XML format: Sitemap file location. sitemaps.org
- Google Search Central. Manage your sitemaps with sitemap index files. developers.google.com
- Google Search Central. Build and submit a sitemap. developers.google.com
- W3C. Date and Time Formats (W3C Datetime), 1997. w3.org