Guide · Sitemaps

XML sitemap validation

A sitemap is a list of URLs you want to communicate to search engines. It is useful when it reflects the site you actually intend to maintain, not every URL the server can technically produce. A valid sitemap does not guarantee crawling, indexing or ranking.

This guide covers the two sitemap roots, the fields that matter, the limits, the entries to leave out, and a validation pass you can repeat before submitting the file.

Two roots: urlset and sitemapindex

A regular sitemap uses <urlset> as the root and one <url> entry per page. A sitemap index uses <sitemapindex> and one <sitemap> entry per child sitemap. The index does not list pages directly; it points to other sitemap files.

<?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <url> <loc>https://example.com/</loc> <lastmod>2026-11-23</lastmod> </url> </urlset>

The namespace is part of the protocol. A file that looks like a sitemap but omits the namespace can be rejected or ignored.

Fields that matter

ElementRequiredWhat to check
<loc>Yes, one per entryAbsolute http or https URL, no whitespace, no fragment, final canonical form.
<lastmod>NoA W3C date such as 2026-11-23 or 2026-11-23T10:00:00+00:00. It should reflect a real change.
<changefreq>NoOne of always, hourly, daily, weekly, monthly, yearly, never.
<priority>NoA number from 0.0 to 1.0. It is a hint, not a ranking control.

For most small sites, loc and a truthful lastmod are the useful fields. Adding a priority to every page does not make the file more effective.

What belongs in a sitemap

  • Public pages that return successfully and represent the preferred URL.
  • The final protocol, host, path and trailing-slash convention.
  • Pages you want a search engine to know about.
  • A real lastmod when the page changed.

Leave out redirects, duplicate parameter URLs, test pages, empty archives, staging URLs, login pages and pages you do not want indexed. A sitemap is not a place to list every internal link.

Limits

The sitemap protocol sets a limit of 50,000 URLs and 50 MB uncompressed per file. A sitemap index can point to up to 50,000 child sitemaps. If a site is larger, split by section or by update pattern and submit the index.

Those are protocol limits, not a target. A 24-page site can use one small file. A file with 24 valid URLs and honest dates is more useful than a 50,000 URL export with duplicates and stale entries.

Common XML mistakes

Malformed XML

An unclosed tag, a stray ampersand or an HTML document saved with an .xml extension will fail to parse. Validate the file as XML before looking at the URLs.

# Not well-formed <urlset> <url><loc>https://example.com/page</loc> </urlset> # Well-formed <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <url><loc>https://example.com/page</loc></url> </urlset>

Relative locations

/page is not a sitemap location. Use the full URL. A relative value may be accepted by a parser but cannot identify the host.

Duplicates

Exact duplicates add noise. Decide which URL is canonical, keep one entry and fix the links that point to the other form.

Wrong host

A sitemap for example.com that lists www.example.com or a staging host sends mixed signals. Use the preferred host consistently. If the other host redirects, leave it out.

Fragments and tracking parameters

#section does not identify a separate page. Tracking parameters can create duplicate URLs. List the canonical URL without the fragment or campaign parameters.

Invalid lastmod

November 2026 is not a W3C date. Use 2026-11-23. Do not update every lastmod to today's date on every deploy; that makes the signal meaningless.

A validation pass

  1. Parse the XML. Confirm the root, namespace and well-formedness.
  2. Count the entries. Check the number against the site you intended to list.
  3. Check every loc. Absolute URL, final host, no whitespace, no fragment, no duplicate.
  4. Check lastmod. Use the real change date. Remove the field if you do not maintain it.
  5. Compare with the live site. Fetch a sample of URLs and confirm the status and canonical.
  6. Submit and inspect. After deployment, submit the sitemap in Search Console and read the report. A valid file can still contain URLs Google chooses not to index.

When a URL changes

A page that moves needs a decision before the sitemap is updated. If the old URL should no longer serve the page, redirect it to the new URL with a 301 and list only the new URL in the sitemap. If both URLs must remain accessible, choose a canonical and list the preferred URL. Do not leave the old URL in the sitemap after a redirect.

When a page is removed and there is no equivalent, return a useful 404 or a 410 and remove the entry from the sitemap. Do not redirect every removed page to the home page; that tells a crawler that unrelated old URLs are now the home page.

After a move, check the old URL, the new URL, the canonical, the sitemap and the internal links. A sitemap that lists the new URL while the navigation still points to the old one is still inconsistent.

What the checker cannot verify

  • Whether each URL returns 200, redirects or 404s. The checker does not fetch them.
  • Whether each page is canonical, indexable or free of noindex.
  • Whether Google has crawled or indexed the sitemap.
  • Whether the XML is served with the correct content type or status.
  • Whether a sitemap index child is reachable or valid. Each child needs its own check.

Sources

Written and tested by Mark. The valid, malformed, duplicate and relative-location cases were run through the sitemap checker and the Test Lab. The checker validates the XML you provide; it does not fetch the URLs.

Found an error? Use the corrections page. Last updated 2026-11-23.