Sitemap Index
A Sitemap Index is an XML directory for managing multiple sitemap files. Learn when to use a sitemap index, how to set it up correctly, and sitemap splitting best practices for large websites.
Definition
A Sitemap Index is an XML file that lists and manages multiple sitemap file locations. According to the sitemaps.org protocol, a single sitemap can contain a maximum of 50,000 URLs and cannot exceed 50MB uncompressed. When your site exceeds these limits, or when you want to manage sitemaps separately by content type (posts, products, categories), language version, or update frequency, you need a sitemap index. Google and other search engines automatically read the sitemap index and crawl all sub-sitemaps listed within.
Why it matters
- Break the 50,000 URL / 50MB limit of single sitemaps—essential for large sites
- Organize by content type (posts, pages, products, categories) for easier management and debugging
- Split by language/region (sitemap-en.xml, sitemap-zh.xml) for international SEO
- Improve update efficiency: only regenerate changed sub-sitemaps, reducing server load
- Submit one index to Google Search Console, automatically covering all sub-sitemaps
- Better tracking: view indexing status of each sub-sitemap separately in GSC
- Support dynamic generation: create multiple sitemaps from database dynamically
How to implement
- Assess necessity: Small sites with < 10,000 URLs and simple structure usually don't need it
- Decide splitting strategy: by content type (most common), update frequency, language, or even URL count
- Generate sub-sitemaps: each file contains same-type URLs, ensuring < 50,000 entries
- Create sitemap index: use <sitemapindex> tag to list all sub-sitemaps with <loc> and <lastmod>
- Set up auto-update: automatically update relevant sub-sitemaps and index lastmod when content changes
- Add Sitemap directive to robots.txt: Sitemap: https://example.com/sitemap-index.xml
- Submit to Google Search Console and monitor indexing status
Examples
xml
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<!-- Static pages -->
<sitemap>
<loc>https://example.com/sitemap-pages.xml</loc>
<lastmod>2025-01-15</lastmod>
</sitemap>
<!-- Blog posts -->
<sitemap>
<loc>https://example.com/sitemap-posts.xml</loc>
<lastmod>2025-01-20</lastmod>
</sitemap>
<!-- Product pages -->
<sitemap>
<loc>https://example.com/sitemap-products.xml</loc>
<lastmod>2025-01-18</lastmod>
</sitemap>
<!-- Multilingual: English -->
<sitemap>
<loc>https://example.com/sitemap-en.xml</loc>
<lastmod>2025-01-20</lastmod>
</sitemap>
<!-- Multilingual: Chinese -->
<sitemap>
<loc>https://example.com/sitemap-zh.xml</loc>
<lastmod>2025-01-19</lastmod>
</sitemap>
</sitemapindex>javascript
// Node.js dynamic sitemap index generation example
const generateSitemapIndex = (sitemaps) => {
const header = '<?xml version="1.0" encoding="UTF-8"?>';
const indexStart = '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
const indexEnd = '</sitemapindex>';
const entries = sitemaps.map(({ url, lastmod }) => `
<sitemap>
<loc>${url}</loc>
<lastmod>${lastmod}</lastmod>
</sitemap>`).join('');
return `${header}\n${indexStart}${entries}\n${indexEnd}`;
};
// Usage example
const sitemaps = [
{ url: 'https://example.com/sitemap-posts.xml', lastmod: '2025-01-20' },
{ url: 'https://example.com/sitemap-products.xml', lastmod: '2025-01-18' },
];
console.log(generateSitemapIndex(sitemaps));Related
Tutorials
Tools
FAQ
Common questions about this term.