问答
Sitemap index vs sitemap: which one do you need?
A sitemap index lists other sitemaps; a sitemap lists pages. When is an index required, why nesting is banned, and which file to submit to Google.
更新于 2026年4月6日 · 约 3 分钟
Both files are XML at a URL, both are named sitemap, and they are not interchangeable. The confusion costs people traffic because they submit the wrong file, or they build an index when a single file would have been simpler and more reliable.
One root element decides everything
The difference is the root tag. urlset holds pages; sitemapindex holds sitemaps.
<!-- A regular sitemap: lists pages -->
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://example.com/pricing</loc>
</url>
</urlset>
<!-- A sitemap index: lists other sitemaps -->
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>https://example.com/sitemap-products.xml</loc>
</sitemap>
</sitemapindex>
An <urlset> entry must contain a <loc> that is a page. A <sitemapindex> entry must contain a <loc> that is another sitemap file. Put the wrong kind of URL in either and the file fails validation.
Sitemap (urlset) | Sitemap index (sitemapindex) | |
|---|---|---|
| Lists | Pages | Other sitemap files |
| Root element | <urlset> | <sitemapindex> |
| Child element | <url> | <sitemap> |
Typical <loc> | https://example.com/page | https://example.com/sitemap-1.xml |
| Limit | 50,000 URLs / 50 MB | 50,000 sitemaps / 50 MB |
When an index becomes mandatory
An index is required in exactly one situation: when your URL set no longer fits in a single file. That means more than 50,000 URLs, or more than 50 MB uncompressed. Until you cross that line, a single sitemap is easier to generate, easier to submit and easier to debug.
A second, softer reason is operational. If different generators produce different parts of the site — a CMS for articles, a build step for products — each can emit its own sitemap, and a small index ties them together. This is a convenience, not a requirement, but it keeps ownership clean.
What an index is not is a ranking boost or a sign of a larger site. Search engines treat the URLs identically whether they arrive through one file or fifty.
Nested indexes are not allowed
The protocol is explicit: a sitemap index references sitemap files, not other indexes. The pattern index.xml → sub-index.xml → urlset.xml is invalid, and crawlers stop at the first level. If you have enough URLs to need sub-indexes, flatten them: one index, many urlset files, no intermediate layer.
What to submit, and what to declare
Submit the index in Search Console and reference the index in robots.txt:
# robots.txt —— 指向 index,而不是子文件
Sitemap: https://example.com/sitemap.xml
The index is the entry point. Children are discovered through it, so listing them separately only fragments your reporting. If you also want crawlers to find child files directly, that is harmless, but it is the index that should appear in both places.
Child sitemaps do not have to sit in the same folder as the index, and they can even be hosted on another domain, as long as every <loc> is absolute and the files are reachable.
Do child sitemaps need lastmod?
It is optional, but worth including. A correct lastmod on each <sitemap> entry tells the crawler which child files changed, so it can fetch only those instead of the whole set. An inaccurate value — the build time stamped on every child — pushes the crawler to re-fetch everything, and it quickly learns to distrust the field.
Common mistakes
Pointing an index at pages. A <sitemapindex> whose entries are regular URLs parses as an error. Each entry must be a sitemap file.
Pointing a sitemap at sitemaps. The mirror mistake: a urlset full of sitemap-*.xml URLs. Validation fails and no pages get discovered.
Building an index for a 200-page site. It adds a moving part with no benefit. Use one file until you genuinely need to split.
Submitting the children. Coverage and error numbers get split across entries, which makes the report harder to read and masks a broken child.
Chaining indexes. Nested indexes are unsupported. Flatten to a single level.
Referencing a child that returns HTML. If a missing sitemap falls through to your SPA index page, the crawler reads HTML where it expected XML. Serve a 404 for missing sitemaps instead.
Where this tool fits
The sitemap validator detects whether a URL is an index or a urlset, follows the index to its children, and reports the entry count and any entries that break the protocol. It is the quickest way to confirm that you built the right kind of file before you submit it.
Frequently asked questions
▸ What is the difference between a sitemap and a sitemap index?
A regular sitemap uses the urlset root and lists pages. A sitemap index uses the sitemapindex root and lists other sitemap files. The index contains loc and lastmod entries that point at child sitemaps, not at pages.
▸ When do I need a sitemap index?
You need one when you exceed 50,000 URLs or 50 MB uncompressed in a single file. Below that a single sitemap is simpler and perfectly valid; an index is a split, not an upgrade.
▸ Can a sitemap index point to another sitemap index?
No. The protocol does not allow nested indexes. A sitemap index may reference urlset sitemap files only, never another index.
▸ Which file do I submit to Search Console?
Submit the sitemap index. That is the file that reveals every child sitemap. Submitting the children as well is redundant and splits your coverage reporting.
▸ Do the child sitemaps need to be in the same directory?
No. Child sitemaps can live anywhere, and even on another host, as long as each loc is an absolute URL and the child sits under the same scope rules as the index.