Common XML Sitemap Errors and How to Fix Them
A symptom-first troubleshooting guide for the XML, HTTP, URL, and indexability errors that make sitemap reports unreliable.
Key takeaways
- Validate the HTTP response before debugging XML.
- A syntactically valid file can still contain poor indexation signals.
- Sitemap URLs should resolve directly to canonical 200 pages.
- Fix generators at the data source instead of patching output files manually.
Error 1: the URL returns HTML instead of XML
A login page, CDN challenge, branded 404, or application error can return status 200 while the body is HTML. Check the final response URL, status, content type, and first bytes of the body. Search engines need the XML document, not a page that visually explains an error.
Error 2: malformed or incorrectly escaped XML
Unescaped ampersands, mismatched tags, invalid control characters, and text before the XML declaration can break parsing. Generate XML with a serializer and escape values at output time instead of concatenating strings.
<loc>https://example.com/catalog?category=books&page=2</loc>This demonstrates escaping, not a recommendation to include every filter URL. Include it only if it is an intended canonical, indexable page.
Error 3: redirecting, missing, or non-canonical URLs
A sitemap should contain final canonical destinations. Redirects waste crawl requests and send mixed signals; 404 and 410 URLs do not belong; alternate tracking or parameter URLs can compete with the preferred page. Resolve each loc and compare it with the page's canonical before publishing.
- Replace HTTP URLs with their final HTTPS versions
- Remove deleted URLs instead of keeping them for historical reporting
- Exclude noindex pages and URLs canonicalized elsewhere
- Use the application's actual trailing-slash and hostname conventions; do not rewrite URLs blindly
Error 4: inaccurate lastmod values
A deployment timestamp applied to every URL says that all pages changed together, even when only application code changed. Repeatedly inaccurate dates reduce the signal's usefulness. Source lastmod from the content record or omit it when you cannot prove a meaningful page change.
Error 5: file and index limits
A sitemap cannot exceed 50,000 URLs or 50 MB uncompressed. Split larger inventories and use a sitemap index. Validate child files independently, because one broken child should not prevent you from diagnosing the rest of the inventory.
Match the symptom to the failing layer
For fetch errors, capture the exact submitted URL, redirect chain, status, and body outside your logged-in session. A 404 suggests a wrong or removed route; 403 can indicate access rules; 429 and 5xx suggest rate limits or temporary server failures. A browser showing styled XML is not itself an error: inspect the downloaded document beneath the stylesheet.
For parse errors, run xmllint --noout on the downloaded, decompressed file and use the line and column it reports. Fix encoding or serialization in the generator. Encoding a query separator as %26 changes the URL; escaping it as & preserves the separator in XML. Avoid double-escaping already serialized values.
What SitemapKit Checker can certify
Checker checks XML syntax, its supported root and namespace, required absolute HTTP(S) loc values, duplicates, multiple hosts, dates, metadata values, and entry and byte limits. It reports date coverage and future-date counts. It is not a complete XSD validator and cannot infer whether a Google cross-site submission has verified ownership.
Pasted XML is checked locally in the browser without fetching pages. URL mode checks HTTP statuses for the first 10 entries of a valid urlset using HEAD requests. An index is checked as a document without recursively validating children. That sample does not inspect canonical tags, meta robots, content quality, or Google's indexing state. Test children separately and use a page audit for those questions.
URL mode requires bot verification and currently allows three requests per hour per IP. Remote transport has a 10 MiB response ceiling, below the protocol's 50 MB limit. A fetch-size failure does not prove the file exceeds the protocol limit; validate a downloaded file or audit smaller children instead.
A clean first-ten-URL sample cannot certify a 50,000-URL inventory. HEAD and GET can behave differently; confirm affected entries with normal page fetches before changing the generator.
When the sitemap succeeds but pages are not indexed
Separate file processing from Page indexing reasons such as noindex, a different selected canonical, or crawled-but-not-indexed. Use URL Inspection for an affected entry and compare it with an eligible page from the same template. A sitemap cannot override noindex, guarantee canonical selection, or establish content quality.
After fixing the generator, fetch the deployed file again and retest a previously failing entry. Compare counts against the intended published set. Reports need time to reflect changes; keep before-and-after evidence rather than treating a later indexing increase as proof that the sitemap fix caused it.
A repeatable validation order
Test transport first, XML second, individual URL quality third, and Search Console processing last. This order prevents you from chasing a report symptom caused by a basic response or serialization failure.
- Fetch the exact submitted URL and record redirects
- Parse and validate the XML namespace and root element
- Sample or crawl loc entries for status, canonical, and robots signals
- Compare the eligible count with your application database
- Resubmit only after the corrected file is publicly available
Inspect accessibility and XML structure with the free checker.
Open the free toolFrequently asked questions
Why does Search Console say a sitemap is HTML?
The submitted URL is likely returning an error page, login screen, redirect destination, or CDN challenge instead of the XML response.
Should redirects remain in a sitemap?
No. Replace them with the final canonical URLs so crawlers do not have to resolve avoidable hops.
Can I omit lastmod?
Yes. A missing lastmod is better than a date that changes automatically without a meaningful content update.
Primary references
Technical content: SitemapKit Engineering. Maintained by Clément Chaal.
See our technical methodology and editorial policy.