DomainLens

Learn

XML Sitemap Example, URL Location, and How to Validate One

A sitemap is a discovery hint, not an indexing instruction. Its value comes entirely from being accurate: every URL canonical, indexable, and returning 200.

Check your site before you start fixing

Run a fresh DomainLens audit and use the report as your priority list.

Run a free SEO audit

XML sitemap example

The format is deliberately small. A urlset element, one url element per page, and a loc element carrying an absolute URL. Everything else is optional, and two of the optional elements are ignored outright by Google.

The example below is complete and valid. Anything more elaborate is either an hreflang annotation or an element that no longer influences anything.

ElementRequiredDoes Google use it?
locYesYes — the URL to discover
lastmodNoYes, if consistently accurate
changefreqNoNo — ignored
priorityNoNo — ignored
xhtml:linkNoYes — for hreflang annotations
A minimal, valid XML sitemap
<?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-08-14</lastmod>
  </url>
  <url>
    <loc>https://example.com/guides/technical-seo</loc>
    <lastmod>2026-07-02</lastmod>
  </url>
</urlset>

Sitemap URL: where the file should live

Put the file at the root, as /sitemap.xml, and reference it from robots.txt. The location is not cosmetic: a sitemap may only list URLs at or below its own directory, so a file at /blog/sitemap.xml cannot legally list anything under /shop/. A root location removes the restriction entirely.

The robots.txt reference matters just as much. It is the only place a crawler is told where the sitemap is without guessing, and it is the first place any checker looks.

  • URLs must be absolute, including the scheme, and must use the exact host you want indexed.
  • Maximum 50,000 URLs and 50 MB uncompressed per file — beyond either limit, split and use a sitemap index.
  • The file must be UTF-8, and ampersands and angle brackets inside URLs must be XML-escaped.
  • lastmod must be a valid W3C date. If you cannot produce an honest value, omit it — a file stamping today on every URL teaches Google to ignore the field.

Sitemap index example for large sites

Past the size limit — or once you want per-segment reporting — the index format points at child sitemaps instead of listing URLs itself. Splitting by section, by locale, or by content type turns one opaque coverage number in Search Console into several readable ones, which is often reason enough to split well before hitting 50,000 URLs.

A sitemap index
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <sitemap>
    <loc>https://example.com/sitemap-en.xml</loc>
    <lastmod>2026-08-14</lastmod>
  </sitemap>
  <sitemap>
    <loc>https://example.com/sitemap-de.xml</loc>
    <lastmod>2026-08-02</lastmod>
  </sitemap>
</sitemapindex>

Sitemap finder: how to locate any site's sitemap

Finding a sitemap is a short search with a clear order of preference. The robots.txt pointer is authoritative; everything after it is convention and guesswork.

  1. 1Read /robots.txt first. A Sitemap: line there is the authoritative pointer.
  2. 2Try the conventional paths: /sitemap.xml, /sitemap_index.xml, /sitemap-index.xml, /sitemap1.xml.
  3. 3Check the platform default — WordPress with Yoast serves /sitemap_index.xml, Shopify serves /sitemap.xml with child files per resource type.
  4. 4Use a site: query restricted to the XML path when the file is already known to Google.
  5. 5If an index is returned, follow each child loc — the URLs live in the children, not the index.
Locating and extracting a sitemap from the command line
# The authoritative pointer
curl -s https://example.com/robots.txt | grep -i sitemap

# Confirm it exists and is served as XML
curl -sI https://example.com/sitemap.xml | head -n 5

# Count the URLs it contains
curl -s https://example.com/sitemap.xml | grep -c '<loc>'

# Extract every URL from a child sitemap
curl -s https://example.com/sitemap-en.xml \
  | grep -oE '<loc>[^<]+' | sed 's/<loc>//'

Sitemap checker and validator: what to test

Validation has two halves, and most tools only cover the first. Syntax validity means the file parses and matches the schema. Content validity means the URLs inside it deserve to be there — and that is the half that decides whether the sitemap helps or hurts.

A sitemap can be perfectly well-formed and still be a liability if a third of its URLs redirect or return 404. Check both.

  1. 1Confirm the file parses as XML and is served with an XML content type, not text/html.
  2. 2Check the response is 200 and is not itself redirected — a sitemap behind a redirect is a common silent failure.
  3. 3Sample the URLs: take twenty at random and verify each returns 200, is self-canonical, and is not noindexed.
  4. 4Submit in Search Console and read the report a few days later. "Couldn't fetch" points at the file; a low discovered count points at its contents.
  5. 5Track submitted against indexed counts over time. A wide, stable gap is a content-quality signal, not a sitemap bug.

Sitemap generator options, and when to skip one

An online sitemap generator crawls your site once and hands back a static file. That is useful for a one-off audit or a site that rarely changes, but it produces a snapshot that starts drifting immediately, and its lastmod values reflect the crawl rather than the content.

Anything that publishes regularly should generate the sitemap from its own data instead, so the file is correct by construction and lastmod is genuinely the content's modification date. Most CMS platforms do this already; for a custom application it is usually a single route.

  • Use a generator for a static brochure site or a one-time inventory of what a crawler can reach.
  • Generate from the database for anything with changing content, so the file cannot go stale.
  • Never hand-edit a generated file — the next regeneration silently discards the change.

How DomainLens contributes

DomainLens checks whether a sitemap is declared in robots.txt, whether it is reachable, and whether it parses — the three failures that stop discovery before it starts. A sitemap cannot force indexing, so when URLs are discovered and then left alone, work through indexability debugging , check for index bloat and crawl discovery , and confirm the declaration itself against robots.txt best practices .

What should the sitemap URL be?
https://yourdomain.com/sitemap.xml, referenced from robots.txt. A sitemap can only cover URLs at or below its own directory, so a root location avoids the restriction entirely.
Do changefreq and priority do anything?
Google ignores both. Only loc, lastmod, and hreflang annotations carry weight, so omitting the other two makes the file smaller and no less useful.
Should noindex pages be listed in the sitemap?
No. A sitemap asks Google to crawl and consider a URL while noindex asks it not to index one. Listing both together is a contradiction that wastes crawl budget.
How often should a sitemap be regenerated?
Whenever content changes, so lastmod stays truthful. A nightly rebuild is fine; a rebuild that stamps today on every URL is worse than having no lastmod at all.

Check this on your own site

Related resources