Automated technical SEO checks that catch indexing blocks and deploy regressions — seotto.com

The protocol is not shy about the limits: a sitemap file may contain at most 50,000 URLs and must be no larger than 50 MB uncompressed. Real sites cross both, sometimes with a comfortable margin (a catalogue) and sometimes overnight (a generator that started including parameters). Search Console then reports "Sitemap could not be read" or "Sitemap is too large", or it quietly stops processing the tail.

The fix is a sitemap index that points at several smaller sitemap files. Here is a straightforward way to produce that and not make a mess.

Know which limit you hit

A file can be under 50,000 URLs and still over 50 MB if the URLs are long or you include a lot of image entries and hreflang. Conversely, short URLs can stay small well past 40,000. Check both:

# URLs (very roughly: <url> entries) grep -c "<url>" sitemap.xml # size wc -c sitemap.xml # if you serve gzip gzip -c sitemap.xml | wc -c 

The 50 MB limit is on the uncompressed file. Gzip is encouraged and does not raise the cap. If you only look at the .gz size you can think you are fine when you are not.

Also confirm the file is actually being fetched: a 200, a correct Content-Type, and not a login page or a compressed file served with the wrong encoding. Size problems and fetch problems get similar messages.

Split on a meaningful boundary, not only a count

You can cut every 40,000 URLs in whatever order the generator emits. You should split in a way a human can debug:

  • one sitemap per section (products-1.xml, products-2.xml, blog.xml, categories.xml)
  • or per locale (sitemap-en.xml, sitemap-de.xml)
  • and still cap each file under the limits, with a margin (I use 40,000 URLs or 40 MB)

When Search Console complains about a file, you want to know what is in it without opening a 50,000-line grab bag. A margin means a small accidental spike doesn't break the file before you notice.

import gzip from pathlib import Path from xml.sax.saxutils import escape OUT = Path("sitemaps") MAX_URLS = 40_000 MAX_BYTES = 40 * 1024 * 1024 BASE = "https://example.com/sitemaps" def url_block(loc, lastmod=None): parts = [f" <url>\n <loc>{escape(loc)}</loc>"] if lastmod: parts.append(f" <lastmod>{escape(lastmod)}</lastmod>") parts.append(" </url>\n") return "".join(parts) def write_chunks(name, urls): OUT.mkdir(exist_ok=True) files = [] chunk, n, size, idx = [], 0, 0, 1 header = '<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n' footer = "</urlset>\n" def flush(): nonlocal chunk, n, size, idx if not chunk: return body = (header + "".join(chunk) + footer).encode("utf-8") dest = OUT / f"{name}-{idx}.xml.gz" dest.write_bytes(gzip.compress(body, mtime=0)) files.append(dest.name) chunk, n, size, idx = [], 0, 0, idx + 1 for loc, lastmod in urls: block = url_block(loc, lastmod) extra = len(block.encode("utf-8")) if n >= MAX_URLS or size + extra + len(footer) > MAX_BYTES: flush() if n == 0: size = len(header.encode("utf-8")) + len(footer.encode("utf-8")) chunk.append(block) n += 1 size += extra flush() return files def write_index(files, lastmod): rows = "\n".join( f" <sitemap><loc>{BASE}/{name}</loc><lastmod>{lastmod}</lastmod></sitemap>" for name in files ) xml = ( '<?xml version="1.0" encoding="UTF-8"?>\n' '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n' f"{rows}\n</sitemapindex>\n" ) (OUT / "sitemap-index.xml").write_text(xml, encoding="utf-8") 

Point robots.txt at the index, not at one child:

Sitemap: https://example.com/sitemaps/sitemap-index.xml 

Submit the same index URL in Search Console. You can submit children too, but the index is the one you want to keep stable as the set of children grows.

Details that cause annoying bugs

Absolute URLs, in both the index and the children. Relative loc values are a common generator bug and are easy to miss until a validator complains.

lastmod should be honest, or omitted. A generator that stamps now() on every URL, every night, teaches nothing and can look like spam. A real last-modified (the page or the product record) is useful. The index's lastmod can be the newest child.

Don't leave the old huge sitemap.xml around if you have moved to an index. Two competing sitemaps, one of which is invalid, will waste time in the Search Console UI.

Stable filenames help. If products-1.xml.gz is "the first 40,000 product IDs" today and a different 40,000 tomorrow, you will get noisier recrawls than if you split by ID range or by a stable section. Perfect stability is not required; wild reshuffling every build is needless.

A sitemap that crosses the limit often shows up as a fetch or parse error, not as a friendly 'this file is too big' on day one. seotto.com checks crawler-facing files after you deploy, so a sitemap that stopped validating, or an index that still points at a missing child, gets caught the same day.

After you switch

Ask Search Console to recrawl the index, and watch which children are "Success" and which still fail. Fetch each child yourself (curl -sSI) and confirm 200, gzip or XML as intended, and a URL count under the cap. Keep a CI assertion: no generated child exceeds MAX_URLS or MAX_BYTES, and every file listed in the index exists in the build artifact.

The sitemap is an interface. Treat a split the way you would treat a pagination bug in any other API: explicit limits, a stable index, and a test that the pages still add up to the collection you meant to publish.

Related reading

Did you hit the 50,000-URL cap or the 50 MB one first, and did Search Console tell you clearly, or did the sitemap just stop updating?