How-to - Technical SEO

How to fix an invalid sitemap in 5 minutes

Validate sitemap XML, fix URL and lastmod errors, remove bad URLs, and resubmit the corrected file.

Technical SEO · Last updated Apr 18, 2026 · 6 min read · BeRelevant.ai
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>/pricing</loc>      invalid: relative URL
  </url>
  <url>
    <loc>https://berelevant.ai/blog</loc>
    <lastmod>2026/04/18</lastmod> invalid: bad date format
  </url>
</urlset>
COVER - sitemap.xml with error markers

TL;DR

  • 01
    Relative URLs in loc are the most common sitemap error. - Always absolute. Always HTTPS. Always match the canonical host.
  • 02
    Wrong lastmod format damages trust. - Google can ignore the whole file's freshness signal when dates are malformed.
  • 03
    Oversized sitemaps are rejected wholesale. - Split anything over 50MB or 50,000 URLs into a sitemap index.
  • 04
    404s and redirects waste crawl budget. - Every sitemap URL should return 200 and be indexable.
  • 05
    Validate, deploy, then resubmit. - Search Console usually re-crawls corrected sitemaps within 24 hours.
01

What the audit checks first

A useful sitemap audit separates parser failures from URL failures. Otherwise teams fix the XML and miss the URLs Google still cannot use.

3
layers
Syntax, URL validity, and crawl policy checked separately
Source: berelevant audit model
50K
URLs
Hard sitemap file limit before a sitemap index is required
Source: sitemaps.org
24
hours
Typical Search Console re-crawl window after resubmission
Source: field audits
01
Parse the raw XML before checking URL status.
syntax layer
02
Normalize every loc to the canonical HTTPS host.
URL layer
03
Remove URLs that redirect, 404, or carry noindex.
policy layer

What counts as an invalid sitemap

Sitemap validation fails at three layers: XML syntax like malformed tags, URL validity like relative paths or wrong protocols, and policy limits like file size or URL count.

Search Console catches many syntax and URL errors. Policy failures can be quieter: the file parses, but a subset of URLs gets dropped.

URL format

Valid sitemap
Absolute HTTPS canonical URL
Invalid sitemap
Relative URL, wrong host, or mixed protocol

HTTP status

Valid sitemap
200 OK and indexable
Invalid sitemap
404, redirect chain, blocked, or noindex

Freshness

Valid sitemap
Valid W3C lastmod when trustworthy
Invalid sitemap
Human date, slashed date, or stale generated value

File limits

Valid sitemap
Under 50MB and 50,000 URLs
Invalid sitemap
Oversized file without a sitemap index

The 5-step fix

Work top to bottom. Stop when your validator passes.

  1. 01

    Validate the raw XML

    Paste the sitemap into an XML validator. Look for unclosed tags, missing namespace declarations, and stray characters before the XML declaration.
  2. 02

    Make every loc an absolute HTTPS URL

    Relative URLs are invalid. The host must also match your canonical domain.
  3. 03

    Fix lastmod to W3C datetime format

    Use dates like 2026-04-18 or 2026-04-18T10:30:00+00:00. Avoid slashes and human-readable date strings.
  4. 04

    Remove 404s, redirects, and noindex URLs

    Every sitemap URL should return 200 OK and be indexable. Redirects, 404s, and noindex pages send weak or contradictory signals.
  5. 05

    Split large files

    Sitemaps have hard limits: 50MB uncompressed and 50,000 URLs. Over either limit, use a sitemap index.
xmlsitemap.xml
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
  <loc>https://berelevant.ai/</loc>
  <lastmod>2026-04-18T10:30:00+00:00</lastmod>
</url>
</urlset>

After you deploy the fix

Resubmit the corrected sitemap in Google Search Console. Google usually re-crawls within 24 hours; index effects take longer. Watch submitted URLs versus indexed URLs. If those numbers do not converge, the problem is usually at the URL level, not in the sitemap file.

Where sitemap failures usually appear
Example audit breakdown
URL status and indexability
44%
Canonical host mismatch
27%
Malformed lastmod
18%
Raw XML parser errors
11%

The thing nobody tells you about sitemap audits

Most sitemap issues are not in the sitemap. They are in the CMS logic that generates it. A sitemap that looks fine today can break again when a migration rewrites URLs or a new content type is added.

The durable fix is a check that runs on every deploy.

#01

Deploy-time sitemap audit

best durable fix

Run the sitemap check every time content generation or routing changes. The failure happens before broken URLs reach production.

Why it wins here
Manual Search Console checks only catch the issue after Google has already seen the broken sitemap.
Best for - Astro, Next.js, CMS, and generated content pipelines

FAQ

How do I find my sitemap URL if I do not know it?

Try /sitemap.xml, /sitemap_index.xml, or check /robots.txt for a Sitemap directive.

Does fixing a sitemap recover lost rankings?

Not directly. It gets pages crawled again, which is a prerequisite for ranking.

Should I include every URL in my sitemap?

No. Include only canonical, indexable URLs that return 200.

Does changefreq or priority matter?

Google says it ignores both. If Google is the only target, omit them.

Can I have multiple sitemaps?

Yes. Use a sitemap index file when splitting by content type.

Related reading

robots.txt, sitemap.xml, and noindex - which wins?

A precedence table and common misconfigurations.

Last updated Apr 14, 2026

Canonical tags: when they help, when they hurt

The wrong-canonical trap that silently drops pages.

Last updated Apr 12, 2026

HTTP status codes Google actually cares about

200, 301, 302, 404, 410, 503, and the soft-404 trap.

Last updated Apr 10, 2026
Technical AI-search optimization

Fix the site-wide constraints.

We find and fix the technical constraints suppressing organic traffic and AI citations across large websites.