XML Sitemap Best Practices: Limits, Index Files and Dead URLs
Audit sitemap URLs, respect size limits and read lastmod correctly. Learn why Google ignores priority and changefreq, and why HTTP 200 is only one check.

Like it ? share it
A small site may need only one sitemap.xml. As the URL list grows, two limits matter: 50,000 URLs per sitemap and 50MB per file before compression. If you exceed either limit, split the list into multiple sitemaps. A sitemap index can point to those files.
A valid XML file is only the first check. The URLs inside it should be the canonical pages you want search engines to discover, rather than old redirects, missing pages or pages carrying noindex.
How to Measure the Size of a Gzipped Sitemap
Measure the XML after you decompress the sitemap. Count the <url> entries in that XML. If either value is above its limit, divide the URL list into two or more sitemaps. The limits for one sitemap are 52,428,800 bytes of uncompressed XML and 50,000 URL entries. Sitemaps protocol · Google's sitemap limits
Measure one gzip file
Use this procedure for a copy of a gzip file from your sitemap generator. It measures a sitemap with a <urlset> root element. For a sitemap index, use this procedure on the sitemap files in the index.
- Copy this code into a file named
measure_sitemap.py. - Put the script in the directory that contains your gzip file.
- If your file has a different name, change the name in
gzip.open. - Enter
python measure_sitemap.pyin that directory. - Compare each value with its limit.
import gzip
import xml.etree.ElementTree as ET
MAX_BYTES = 52_428_800
MAX_URLS = 50_000
NS = "{http://www.sitemaps.org/schemas/sitemap/0.9}"
def measure(gzip_file):
xml = gzip_file.read(MAX_BYTES + 1)
if len(xml) > MAX_BYTES:
return len(xml), None
root = ET.fromstring(xml)
if root.tag != f"{NS}urlset":
raise ValueError("Expected a sitemap with a urlset root.")
return len(xml), len(root.findall(f"{NS}url"))
with gzip.open("sitemap.xml.gz", "rb") as source:
byte_count, entries = measure(source)
if entries is None:
print(f"XML has at least {byte_count:,} bytes. Byte limit exceeded.")
else:
print(f"XML bytes: {byte_count:,}")
print(f"URL entries: {entries:,}")
if entries > MAX_URLS:
print("URL entry limit exceeded.")
else:
print("Within both limits.")The script reads a maximum of 52,428,801 bytes. If it reads that many, it shows a minimum size and stops before the URL count. For a file within the byte limit, it counts the <url> elements directly under <urlset>. Line breaks can change the line count. The URL count stays the same if the entries stay the same. Python gzip reference · Python ElementTree reference
Four local tests at the limits
We used Python 3.12.6 to measure four test files. The last two gzip files had the same size. One XML file was exactly at the byte limit. The other XML file had one more byte.
| Test file | Gzip bytes | XML bytes | URL entries in the sample | Result |
|---|---|---|---|---|
| At the URL limit | 125,459 | 2,500,071 | 50,000 | Within both limits |
| One extra URL entry | 125,464 | 2,500,121 | 50,001 | Over the URL limit |
| At the byte limit | 168,858 | 52,428,800 | 30,000 | Within both limits |
| One extra XML byte | 168,858 | 52,428,801 | 30,000 | Over the byte limit |
The test generator set the number of entries in each sample. The script did not count the entries in the last test file. These tests used generated data on one computer. They did not test sitemap acceptance in Search Console.
Measure the files after you divide the list
- If either value is above its limit, divide the list in the sitemap generator.
- Generate the new sitemap files.
- Measure each new file before you send it to Google.
- Add the sitemap URLs to a sitemap index.
- Send the sitemap index URL in the Search Console Sitemaps report.
Search Console has different messages for a compression error, a file size error, and too many URLs. If the report shows a compression error, examine the gzip file before you measure its size. Search Console Sitemaps report
For a public sitemap, the Enfect Sitemap Error Checker can read a URL and decompress a gzip file. Use the local script for the byte and URL counts. For a response with an HTML body, use the sitemap response check.
What a sitemap index contains
A standard sitemap lists pages. A sitemap index lists sitemap files. A structure might separate content by type:
sitemap_index.xml
post-sitemap.xml blog posts
page-sitemap.xml static pages
product-sitemap.xml product pagesSeparating the files can make troubleshooting easier. If product discovery drops, you can inspect the product sitemap directly. Each child sitemap still needs to satisfy the URL and uncompressed-size limits. Gzip compression can reduce transfer size, but it does not raise those limits.
Google's sitemap guidance covers these requirements. Submission helps discovery; it does not guarantee crawling or indexing.
Find a Nested Sitemap Index
For Google Search Console, put only sitemap URLs in the index. If the index contains its own URL or the URL of a second index, Google can show the error Incorrect sitemap index format: Nested sitemap indexes. Sitemaps report
Find the type of each XML file
- Open the sitemap index URL from the Sitemaps report.
- Record the URL in the
<loc>element of each<sitemap>entry. - Open each URL in your list.
- Record the root element of each XML file.
- Compare each URL with the URL from step 1.
For these XML files, <urlset> contains page URLs. The root element <sitemapindex> identifies an index. The two types of file can have the same filename extension, .xml. Sitemaps protocol
For a sitemap available on the web, use the Enfect Sitemap Error Checker. The tool shows “nested indexes are followed”. Use the Sitemaps report for the result from Google.
Change the index
This example uses one index at https://example.com/sitemap.xml. Each entry has the URL of a different type of XML file.
| URL path in the index | Root element | What the file contains |
|---|---|---|
/sitemaps/posts.xml |
<urlset> |
Page URLs |
/sitemaps/catalog.xml |
<sitemapindex> |
The URL of /sitemaps/products.xml |
Remove the entry for catalog.xml. Add an entry for products.xml with its full URL. Keep the entry for posts.xml. If the index contains its own URL, remove that entry. The index then contains these entries.
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap><loc>https://example.com/sitemaps/posts.xml</loc></sitemap>
<sitemap><loc>https://example.com/sitemaps/products.xml</loc></sitemap>
</sitemapindex>If you keep more than one index, do the procedure below for each index. For this example, keep each sitemap in the directory of its index or in a subdirectory. Google's sitemap index instructions
Compare the test results
We used Python 3.12.6 to read six XML files for this test. The three index files had the same root element. The table shows the root element at each URL in an index entry.
| Test input | Root elements of the target files |
|---|---|
| Index with an entry for the catalog index | <urlset>, <sitemapindex> |
| Index with entries for posts and products | <urlset>, <urlset> |
| Index with its own URL | <sitemapindex> |
The test used only the XML from the six examples. It made no network requests.
Send the index URL to Google
- Open the Sitemaps report for your site.
- Enter the corrected index URL in the Add a new sitemap box.
- Select Submit.
- Open the row for the index to see its status.
Google's procedure to send a sitemap URL
For a response that contains HTML, use the Enfect procedure to read the sitemap response.
Extract the URLs before checking them
Open the Sitemap URL Extractor and enter the sitemap or index address. A standard sitemap returns page URLs. An index returns the addresses of its child sitemap files, so check the reported file type before treating the result as a page list.
For an index, open each child sitemap in the extractor, export its page URLs, and combine the URL columns for the audit. The current tool does not automatically flatten the index into all of its child pages. If a downloaded .xml.gz file does not parse, decompress it first or use an available uncompressed XML version.
Review the extracted URLs and metadata, then export CSV. The extractor offers an optional status check, but on an index that checks the listed sitemap files. Extract the child pages before checking page responses. For a separate pass over a URL column, use the Bulk URL Checker; the Excel-to-CSV guide shows a complete run.
Keep file extraction and URL checking separate in your interpretation. Successfully parsing a sitemap does not establish that every listed page works. Checking HTTP responses does not establish that Google indexed the pages.
Check lastmod and canonical URLs
lastmod should reflect the last significant change to the page. A date from two years ago on a page you rewrote last month can reveal a generator that misses updates. Setting every page to today's date whenever the sitemap regenerates can be misleading too.
For Google, <priority> and <changefreq> are ignored. You may see those columns in an extracted file, but adjusting them is not a Google ranking or crawl-frequency control. Focus on accurate lastmod values and the actual pages being listed. Google documents these metadata rules here.
Use complete absolute URLs with the intended scheme and host. Prefer each page's canonical address rather than including every parameter variant or an old address that redirects to it.
Check Sitemap Dates After a Rebuild
Keep the old <lastmod> date if the page had no significant change. If the page changed, use the date of its last significant change. If you cannot verify a date, omit the optional tag for that page. Sitemaps protocol
These instructions apply to page URLs in a sitemap. Google can use the date when it can verify its accuracy over time. A new fare in a price table changes the main content. A change to the copyright year alone does not qualify. Google Search Central
Compare two copies of the sitemap
- Save a copy of the sitemap before the rebuild.
- Save a second copy after the rebuild.
- Find the same page URL in both copies.
- Record the
<lastmod>value from each copy. - Find the last significant change in the revision history for that page.
- Compare its date with the value in the second copy.
An old date can be correct. Two identical dates can also hide a missed edit. The revision history helps you tell the difference.
Three pages from one rebuild
In this local example, a transit site generates its sitemap on November 21. All dates in the table are in November 2026.
| Page | Before | After | Page history | Correct entry |
|---|---|---|---|---|
| Hours | Nov 1 | Nov 21 | The hours last changed on Nov 1. | Keep Nov 1. |
| Fares | Nov 2 | Nov 2 | The editor added a new fare on Nov 20. | Use Nov 20. |
| Map | No tag | Nov 21 | The date of the last change is unknown. | Omit the tag. |
An XML parser read both sample files. All three page URLs occurred in both files. The dates in the table came from a comparison with separate sample records.
Check the next rebuild
Find the field that supplies the date to the sitemap generator. For the fares page, the source record must identify the fare change on November 20. A build log only tells you when the build ran.
Generate the sitemap again with the same page records. Check that the hours and fares entries keep their correct dates. Check that the map entry still contains its URL.
Use the Enfect Sitemap Error Checker to examine the XML structure. Use the page history to verify the date itself.
Interpret the responses
| Finding | Meaning | Action |
|---|---|---|
Final response 200 |
The request succeeded | Check content, canonical and indexing directives where relevant |
404 or 410 |
The resource is not found or is gone | Remove an obsolete entry; check for a wrong address before deleting a valid page |
| A redirect found with a redirect check | The listed address leads elsewhere | Use the intended canonical destination in the sitemap |
403 or 429 |
Access was refused or rate limited | Review access controls or retry before treating the URL as missing |
5xx or timeout |
The request failed | Investigate server availability and retry |
Both the bulk checker and the extractor's status check follow redirects. A redirect ending at a working page may therefore show 200, hiding the initial 301 or 302 from that results table. Use the Redirect Detector when you need the hops and destination, then compare that destination with the expected canonical page.
HTTP 200 needs another check when indexing is the concern. A page can return a successful status while showing an error message, pointing its canonical elsewhere or carrying noindex. Use Search Console URL Inspection for pages you own; its indexing report answers a different question from a URL status check.
Check durations depend on list size and target servers. A short healthy list may finish quickly, while slow responses, retries and rate limits can stretch a run. Keep the tab open during a check and wait for completion before exporting the final results.
Fix the source and submit the file
When a generated sitemap contains deleted pages, fix the generator or its source data so the entries do not return on the next build. If an old URL has a relevant replacement, a redirect may still help visitors and existing links; the sitemap should list the replacement's canonical address.
Keep intentionally non-indexable pages out of the sitemap. If a useful page was accidentally marked noindex, fix that directive rather than silently deleting it from the list. For crawl restrictions, compare the URL with robots.txt as a separate step.
You can submit a sitemap index in Search Console and let Google discover its children. Google also allows multiple sitemap or index submissions; separate submissions can help you track sections individually. Choose the arrangement that helps you monitor the site, rather than submitting duplicates to increase coverage.
Keep the old address list for a separate migration redirect audit. The current sitemap cannot substitute for that list.
Recheck after migrations, changes to canonical URLs, large deletions and sitemap-generator updates. Save the exported results so the next audit can distinguish new failures from ones already being investigated.