Large Sitemaps
When your site has thousands of URLs, the plugin automatically handles sitemap splitting according to Google's guidelines.
Automatic Splitting
The plugin automatically splits sitemaps when they exceed:
- 50,000 URLs per sitemap file
- 45 MB file size (with 5 MB buffer from Google's 50 MB limit)
No configuration required - it just works.
How It Works
When splitting is triggered:
- Routes are distributed across multiple sitemap files
- Each file is named sequentially:
sitemap-0.xml,sitemap-1.xml, etc. - A
sitemap-index.xmlis generated referencing all sitemap files
Example Output
For a site with 120,000 URLs:
dist/
├── sitemap-0.xml # URLs 1-50,000
├── sitemap-1.xml # URLs 50,001-100,000
├── sitemap-2.xml # URLs 100,001-120,000
└── sitemap-index.xml # References all sitemapsGenerated Index File
xml
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>https://example.com/sitemap-0.xml</loc>
<lastmod>2025-01-15</lastmod>
</sitemap>
<sitemap>
<loc>https://example.com/sitemap-1.xml</loc>
<lastmod>2025-01-15</lastmod>
</sitemap>
<sitemap>
<loc>https://example.com/sitemap-2.xml</loc>
<lastmod>2025-01-15</lastmod>
</sitemap>
</sitemapindex>Named Exports with Splitting
When using named exports, each export can be split independently:
typescript
// Large product catalog
export async function products(): Promise<Route[]> {
// Returns 75,000 routes
return await fetchAllProducts();
}
// Large blog archive
export async function blog(): Promise<Route[]> {
// Returns 60,000 routes
return await fetchAllPosts();
}Output:
dist/
├── sitemap-products-0.xml # Products 1-50,000
├── sitemap-products-1.xml # Products 50,001-75,000
├── sitemap-blog-0.xml # Posts 1-50,000
├── sitemap-blog-1.xml # Posts 50,001-60,000
└── sitemap-index.xml # References all 4 sitemapsPerformance Considerations
Memory Usage
For extremely large sitemaps, consider:
- Streaming data - Don't load all routes into memory at once
- Pagination - Fetch routes in batches
typescript
export default async function getRoutes(): Promise<Route[]> {
const routes: Route[] = [];
let page = 1;
const pageSize = 10000;
while (true) {
const batch = await fetchRoutes({ page, pageSize });
if (batch.length === 0) break;
routes.push(...batch);
page++;
}
return routes;
}Build Time
Large sitemaps increase build time. To optimize:
- Cache API responses - Store fetched data locally during development
- Parallel fetching - Use
Promise.allfor independent data sources
typescript
export default async function getRoutes(): Promise<Route[]> {
// Parallel fetching
const [products, posts, pages] = await Promise.all([fetchProducts(), fetchPosts(), fetchPages()]);
return [...products, ...posts, ...pages];
}robots.txt with Split Sitemaps
When generateRobotsTxt is enabled with split sitemaps, the Sitemap directive points to the index file:
txt
User-agent: *
Allow: /
Sitemap: https://example.com/sitemap-index.xmlMonitoring Sitemap Size
Use the CLI to check sitemap sizes without building:
bash
vite-sitemap preview --verboseOutput shows size information:
bash
ℹ Preview: default (75,000 routes)
Size: 12.4 MB
Routes: 75,000
⚠ Sitemap will be split into 2 files (exceeds 50,000 URL limit)Google Search Console
After deploying split sitemaps:
- Submit
sitemap-index.xmlto Google Search Console - Google will automatically discover all child sitemaps
- Monitor indexing status for each sitemap file
Best Practices
- Use the index file - Always submit the index, not individual sitemaps
- Keep URLs consistent - Don't change URL structures between builds
- Update incrementally - Only regenerate sitemaps when content changes
- Monitor coverage - Check Search Console for indexing issues