# Stay within 50,000 URLs and 50 MB uncompressed per sitemap

- Check 03.11 · Crawling · Critical
- Source: https://checklist-seo-geo.com/en/crawling/stay-within-50000-urls-50-mb-uncompressed-per-sitemap
- Measure every sitemap, keep it under 50,000 URLs and 50 MB uncompressed, split it automatically with a safety margin, and serve compressed files correctly.
- Updated on 2026-11-25
- Licence: CC BY 4.0. Credit “Checklist SEO & GEO” with a link to https://checklist-seo-geo.com/en/crawling/stay-within-50000-urls-50-mb-uncompressed-per-sitemap.
- Plugin checklist-seo-geo: 1.3.1 · https://github.com/maximegaul/checklist-seo-geo

## In short

The sitemap protocol sets two limits per file: 50,000 URLs and 50 MB (52,428,800 bytes) once uncompressed. Google and Bing apply the same limits, and a sitemap index follows the same rules for the number of files it lists. Once this check is done, every file is measured automatically, the generator splits before reaching either limit, and `.gz` compressed files are served without errors.

## Why it matters

These limits are rules of the format, not recommendations. A file that exceeds them is reported as an error in Search Console, and there is no guarantee that URLs beyond the limit are read. The problem is all the more insidious because it creeps up gradually: one day a catalog sitemap crosses the line without anyone noticing, and the most recently added products stop being reported to search engines.

The two limits are not reached at the same point:

- **A simple sitemap** (URL and `lastmod`) takes about 100 to 200 bytes per entry: it hits 50,000 URLs long before 50 MB.
- **An enriched sitemap** hits the size limit first. With hreflang annotations for ten languages, each entry carries eleven `xhtml:link` tags and can exceed a kilobyte: 50,000 entries then exceed 50 MB. Image sitemaps, which accept up to 1,000 `<image:image>` tags per URL, are in the same situation.

One last trap: compression. An 8 MB `.xml.gz` file can contain 70 MB of XML. The limit applies to the uncompressed file.

## What it improves

- **Crawling**: every listed URL is actually read and queued.
- **Reliable reports**: no more size errors in Search Console, and no segments silently truncated.
- **Performance**: smaller files are faster to generate, serve and re-read.
- **Rankings**: no direct effect.

## How to check

For each file, measure the number of URLs and the uncompressed size:

```bash
SITEMAP=https://example.com/sitemaps/sitemap-produits-1.xml

curl -s --compressed "$SITEMAP" | grep -o '<url>' | wc -l
curl -s --compressed "$SITEMAP" | wc -c
```

For a `.xml.gz` file, decompress explicitly:

```bash
curl -s https://example.com/sitemaps/sitemap-produits-1.xml.gz | gunzip | grep -o '<url>' | wc -l
curl -s https://example.com/sitemaps/sitemap-produits-1.xml.gz | gunzip | wc -c
```

For an index, count the `<sitemap>` entries the same way: 50,000 at most.

Compliant result: under 50,000 for the first figure and under 52,428,800 for the second, ideally with a margin of at least 10%.

Also check the formatting rules, which cause parsing errors:

```bash
# Well-formed XML (xmllint ships with libxml2 on macOS and most distributions)
curl -s --compressed "$SITEMAP" | xmllint --noout - && echo "Valid XML"

# Length of the longest URL: it must stay under 2,048 characters
curl -s --compressed "$SITEMAP" | grep -o '<loc>[^<]*' | awk '{ if (length($0) - 5 > max) max = length($0) - 5 } END { print max " characters" }'
```

In the Search Console [Sitemaps report](https://search.google.com/search-console/sitemaps), an oversized file shows up as an error; click it for the details. In Screaming Frog, the “XML Sitemap With Over 50k URLs” and “XML Sitemap With Over 50mb” filters in the `Sitemaps` tab flag files over the limit after a crawl with `Crawl Linked XML Sitemaps`.

## How to implement

### Before you start

The limits to respect:

| Item | Limit | Source |
|---|---|---|
| URLs per sitemap | 50,000 | sitemaps.org, Google, Bing |
| Sitemap size, uncompressed | 50 MB (52,428,800 bytes) | sitemaps.org, Google |
| Sitemaps listed in an index | 50,000 | sitemaps.org, Google, Bing |
| Index size, uncompressed | 50 MB | sitemaps.org |
| Indexes submitted per site in Search Console | 500 | Google |
| URL length (`<loc>`) | under 2,048 characters | sitemaps.org |
| Images per `<url>` (image sitemap) | 1,000 | Google |
| URLs per Google News sitemap | 1,000 | Google |

Related formatting rules: UTF-8 encoding, absolute URLs on the same host and protocol as the sitemap, special characters escaped (`&` becomes `&amp;`, `<` becomes `&lt;`, `'` becomes `&apos;`, `"` becomes `&quot;`).

Splitting method: set a batch size with a margin, then check the file size. A simple formula for the batch size:

```txt
batch size = min(45,000; floor(47,000,000 / average entry size in bytes))
```

Example: an entry with hreflang for ten languages weighs 1,300 bytes; 47,000,000 / 1,300 = 36,153; use 35,000 URLs per file. Measure the average entry size on an existing file: uncompressed size divided by the number of URLs. The splitting itself and the choice of segments are covered in [split large sitemaps](https://checklist-seo-geo.com/en/crawling/split-large-sitemaps).

> **Good to know:** HTTP compression (`Content-Encoding: gzip` or `br` added by the server) and a `.xml.gz` file are two different things. In both cases, the 50 MB limit applies to the uncompressed XML. Compression reduces the transfer, not the count.

### Apache

Versions: Apache 2.4.

If you publish `.xml.gz` files, serve them as gzip files, without a `Content-Encoding` header that would make some clients decompress them on the fly. In the virtual host or in the `.htaccess` of the sitemaps folder:

```apache
<IfModule mod_mime.c>
    RemoveEncoding .gz
    AddType application/gzip .gz
</IfModule>

<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE application/xml text/xml
</IfModule>
```

The second part compresses uncompressed sitemaps in transit. Reload with `sudo apachectl configtest && sudo systemctl reload apache2`.

### Nginx

Versions: Nginx 1.18 and later.

In the `server` block:

```nginx
location ~* \.xml\.gz$ {
    types { }
    default_type application/gzip;
}

gzip on;
gzip_types application/xml text/xml;
```

For sitemaps regenerated by a scheduled job, write to a temporary file first, then rename it (`mv sitemap.tmp sitemap.xml`): the crawler never reads a half-written file. Reload with `sudo nginx -t && sudo systemctl reload nginx`.

### Cloudflare

Versions: Cloudflare dashboard, all plans, November 2026.

Cloudflare compresses XML responses on the fly and does not change their content: the limit remains that of the origin file. Just make sure the sitemap is not served from cache for too long after it is regenerated: a short cache rule on `/sitemap*` ([Cache Rules](https://dash.cloudflare.com/?to=/:account/:zone/caching/cache-rules)) or a purge after generation prevents serving an outdated file. A sitemap larger than the maximum cacheable file size of your plan is simply not cached.

### AWS

Versions: Amazon S3 and CloudFront, console and AWS CLI v2, November 2026.

On **S3**, upload `.xml.gz` files with the `application/gzip` type, or compressed `.xml` files with the `Content-Encoding: gzip` metadata:

```bash
aws s3 cp sitemaps/ s3://mon-bucket/sitemaps/ --recursive --exclude "*" --include "*.xml.gz" --content-type application/gzip
```

With **CloudFront** in front of the bucket, invalidate `/sitemap*` after each generation. CloudFront only compresses files up to 10 MB on the fly: above that, upload files that are already compressed.

### WordPress

Versions: WordPress 5.5 to 7.1; Yoast SEO 20 to 28; Rank Math 1.0.

Common generators split well below the limits: 1,000 entries per file for Yoast SEO, 200 by default for Rank Math, 2,000 for the native WordPress sitemap. Nothing to do, unless you raised these values with a filter (`wpseo_sitemap_entries_per_page`, `wp_sitemaps_max_urls`): in that case, stay under a few thousand, because these sitemaps are generated on demand and a very long file slows down the response, up to a timeout error.

### Shopify

Versions: Shopify, all plans, November 2026.

Shopify generates and splits its sitemaps itself; there is nothing to configure. Just check the figures with the commands above if the catalog is very large.

### Magento

Versions: Magento Open Source and Adobe Commerce 2.4.7 to 2.4.9.

In `Stores > Configuration > Catalog > XML Sitemap`, the Sitemap File Limits section has two settings: the maximum number of URLs per file (50,000 by default) and the maximum file size in bytes (10,485,760 by default, i.e. 10 MB). Magento splits and creates an index when either is reached. The default values already respect the limits; do not raise them above 50,000 URLs and 52,428,800 bytes.

### Laravel

Versions: Laravel 11 to 13; spatie/laravel-sitemap 7.3 and 8.x.

Automatic splitting only exists in version 8 of the package, which Composer installs on Laravel 12 and 13 with PHP 8.4 or later. Whatever the version, add a check after generation that fails if a file exceeds the limits:

```php
use Illuminate\Support\Facades\File;
use RuntimeException;

foreach (File::glob(public_path('sitemap*.xml')) as $path) {
    $content = File::get($path);
    $urlCount = substr_count($content, '<url>');
    $bytes = strlen($content);

    if ($urlCount > 50000 || $bytes > 52428800) {
        throw new RuntimeException("Sitemap too large: {$path} ({$urlCount} URLs, {$bytes} bytes)");
    }
}
```

#### spatie/laravel-sitemap 8 (Laravel 12 and 13)

`maxTagsPerSitemap()` automatically splits into numbered files (`sitemap_0.xml`, `sitemap_1.xml`…) and writes an index in place of the requested file:

```php
use App\Models\Product;
use Spatie\Sitemap\Sitemap;

Sitemap::create()
    ->maxTagsPerSitemap(45000)
    ->add(Product::query()->where('status', 'active')->get())
    ->writeToFile(public_path('sitemap.xml'));
```

For a catalog of several hundred thousand rows, avoid loading every model into memory: walk through the table with `lazyById()` and write one file per batch, as in the next tab.

#### spatie/laravel-sitemap 7 (Laravel 11 and 12)

This version does not split on its own: write one file per batch of 45,000 rows, then the index with `SitemapIndex`:

```php
use App\Models\Product;
use Illuminate\Support\Collection;
use Spatie\Sitemap\Sitemap;
use Spatie\Sitemap\SitemapIndex;

$index = SitemapIndex::create();

Product::query()
    ->where('status', 'active')
    ->chunkById(45000, function (Collection $products, int $page) use ($index): void {
        Sitemap::create()
            ->add($products)
            ->writeToFile(public_path("sitemap-products-{$page}.xml"));

        $index->add("/sitemap-products-{$page}.xml");
    });

$index->writeToFile(public_path('sitemap.xml'));
```

`SitemapIndex` turns each path into an absolute URL based on `APP_URL`: make sure it is set to the canonical host in production.

### Next.js

Versions: Next.js 15 and 16 (App Router).

The example in the `generateSitemaps()` documentation splits by ID range: if IDs are not contiguous, the files are uneven, and an inclusive `BETWEEN` clause over 50,000 IDs can return 50,001 rows. Split by offset instead, with a margin:

```ts
// app/products/sitemap.ts
import type { MetadataRoute } from 'next'
import { countProducts, getProducts } from '@/lib/products'

const CHUNK_SIZE = 45000

export async function generateSitemaps() {
  const total = await countProducts()
  const chunkCount = Math.ceil(total / CHUNK_SIZE)

  return Array.from({ length: chunkCount }, (_, id) => ({ id }))
}

export default async function sitemap(props: {
  id: Promise<string>
}): Promise<MetadataRoute.Sitemap> {
  const id = Number(await props.id)
  const products = await getProducts({
    orderBy: 'id',
    offset: id * CHUNK_SIZE,
    limit: CHUNK_SIZE,
  })

  return products.map((product) => ({
    url: `https://example.com/products/${product.slug}`,
    lastModified: product.contentUpdatedAt,
  }))
}
```

The files are served at `/products/sitemap/0.xml`, `/products/sitemap/1.xml`… Since Next.js 16, `id` is passed as a promise of a string, hence the `await` and the conversion. On Next.js 15, it is passed directly: write `sitemap({ id }: { id: number })` and remove the `await`. Next.js does not create an index: see the Next.js section of [split large sitemaps](https://checklist-seo-geo.com/en/crawling/split-large-sitemaps).

### Astro

Versions: Astro 5 to 7; @astrojs/sitemap integration 3.x.

The `@astrojs/sitemap` integration caps each file at 45,000 entries by default (`entryLimit` option) and creates `sitemap-index.xml` as soon as more than one file is needed. If your entries carry many language annotations, lower `entryLimit` using the formula above.

## Common mistakes

- **Measuring the compressed file**: an 8 MB `.gz` can exceed 50 MB once decompressed.
- **Forgetting the weight of annotations**: hreflang and images push a file past 50 MB long before 50,000 URLs.
- **Aiming for exactly 50,000**: one URL added between the count and the write, or an inclusive bound, and the file is over the limit. Keep a margin.
- **Counting lines with `grep -c`**: a sitemap written on a single line returns 1. Count the tags with `grep -o '<url>' | wc -l`.
- **Letting an on-demand generator produce a huge file**: generation takes longer than the crawler is willing to wait, and it receives a `5xx` error.
- **Not escaping the ampersand**: a single URL with an unescaped `&` makes the whole file invalid.
- **Serving the `.gz` with `Content-Encoding: gzip`** by accident: depending on the client, the file is decompressed once too often or not enough. Test the response with `curl -I`.

## Frequently asked questions

### What happens if a sitemap exceeds 50,000 URLs?

A sitemap with more than 50,000 URLs falls outside the protocol: Search Console reports it as an error, and nothing guarantees that URLs beyond the limit are read. Split it into several files of fewer than 50,000 URLs each, with a margin, and list them in a sitemap index that you submit to Google and Bing. The same rule applies to the files listed in an index.

### Does the 50 MB limit apply to the compressed file?

No, the 50 MB limit applies to the uncompressed sitemap, that is 52,428,800 bytes of XML. You can gzip a sitemap to reduce the transfer, but an 8 MB .xml.gz file can contain more than 50 MB of XML and exceed the limit. Always measure the size after decompression, for example with curl followed by gunzip and wc.

### How many URLs should I put in each sitemap?

Stay under 50,000 URLs and 50 MB uncompressed, with a margin of at least 10%. For a simple sitemap, 45,000 URLs per file works well; Astro's sitemap integration actually uses this value by default. For a sitemap loaded with hreflang or image annotations, calculate the batch size from the average entry size, because the size limit will be reached first.

### Should sitemaps be gzip-compressed?

It is not required. Google and Bing accept .xml.gz files, which reduce the transfer and help with large catalogs. An uncompressed .xml sitemap served with HTTP compression enabled on the server transfers just as little data and remains readable in a browser. In both cases, the 50 MB limit applies to the uncompressed XML.

## Resources

- [sitemaps.org protocol: limits and format](https://www.sitemaps.org/protocol.html)
- [Google: Build and submit a sitemap](https://developers.google.com/search/docs/crawling-indexing/sitemaps/build-sitemap)
- [Google: Manage large sitemaps](https://developers.google.com/search/docs/crawling-indexing/sitemaps/large-sitemaps)
- [Search Console Help: Sitemaps report](https://support.google.com/webmasters/answer/7451001)
- [Bing: Sitemaps in AI-powered search](https://blogs.bing.com/webmaster/July-2025/Keeping-Content-Discoverable-with-Sitemaps-in-AI-Powered-Search)
- [Adobe Commerce: XML sitemap configuration](https://experienceleague.adobe.com/en/docs/commerce-admin/config/catalog/xml-sitemap)
- [Next.js: generateSitemaps](https://nextjs.org/docs/app/api-reference/functions/generate-sitemaps)
- [Astro: @astrojs/sitemap integration](https://docs.astro.build/en/guides/integrations-guide/sitemap/)

Next steps: [submit sitemaps to Google and Bing](https://checklist-seo-geo.com/en/crawling/submit-sitemaps-google-bing) and [monitor canonicals and sitemaps](https://checklist-seo-geo.com/en/automation-quality-control/monitor-canonicals-sitemaps).
