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/search?category=seo&page=2</loc>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
- Normalize trailing slash and hostname conventions
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.
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
See our technical methodology and editorial policy.