Key takeaways

  • A valid sitemap needs only urlset with the sitemaps.org namespace, url and loc; lastmod is optional and uses W3C Datetime.
  • Past 50,000 URLs or 50 MB uncompressed, split the file and list the parts in a sitemapindex.
  • Check the deployed file with the seogeoaeo.ai XML Sitemap Validator, which also catches scope and size problems a schema check misses.

Here is a minimal XML sitemap example that follows the sitemaps.org protocol, followed by a sitemap index example and the mistakes that most often break them. Copy the shape, swap in your URLs, then run the result through a validator such as the seogeoaeo.ai XML Sitemap Validator before you ship it.

A minimal 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-10-20</lastmod>
  </url>
  <url>
    <loc>https://example.com/docs/install</loc>
    <lastmod>2026-09-02T14:30:00+00:00</lastmod>
  </url>
</urlset>

Line by line:

  • The XML declaration sets UTF-8, which the protocol requires.
  • urlset is the root and must carry the namespace http://www.sitemaps.org/schemas/sitemap/0.9.
  • Each page gets a url element with one loc. Those three tags are the only required ones.
  • lastmod is optional and uses W3C Datetime. A plain date such as 2026-10-20 is valid, and so is a full timestamp with a time zone.

You will see changefreq and priority in many generated files. The protocol allows them, but Google's documentation says it ignores both, so there is no reason to add them by hand.

A sitemap index example

Once a site passes 50,000 URLs or 50 MB uncompressed in one file, split it and point to the parts from an index:

<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <sitemap>
    <loc>https://example.com/sitemaps/pages.xml</loc>
    <lastmod>2026-10-20</lastmod>
  </sitemap>
  <sitemap>
    <loc>https://example.com/sitemaps/docs.xml.gz</loc>
  </sitemap>
</sitemapindex>

The root changes to sitemapindex, and each child is a sitemap with its own loc. Gzip-compressed children are allowed. An index can only list sitemaps on the same site.

Mistakes that break these examples

Mistake Example Fix
Unescaped ampersand ?a=1&b=2 inside loc Write &amp;
Relative URL <loc>/docs/install</loc> Use the full absolute URL
Wrong host https://www.example.com/... in a sitemap on example.com Keep one host and protocol per sitemap
Out of scope A sitemap at /blog/sitemap.xml listing /pricing Move the file to the root
Bad date <lastmod>20/10/2026</lastmod> Use 2026-10-20
Missing namespace <urlset> with no xmlns Add the sitemaps.org namespace

The scope rule trips up a lot of developers: a sitemap may only list URLs at or below its own folder, on the same protocol and host. Subdomains count as different hosts.

Validate the example before you ship it

Two quick ways to check a file:

  1. Locally, with xmllint and the published schema. sitemaps.org links schemas for both file types, and xmllint's --schema option validates against a W3C XML Schema. This catches structural errors in a build step.
  2. Live, with the seogeoaeo.ai validator. Give it the deployed URL and it checks well-formed XML, the namespace, size and count against Google's limits, URL scope and lastmod, then lists the failing entries. It costs 10 credits a run and can be called over a REST API or MCP from CI.

Schema validation alone misses scope and Google's limits, which is why the live check is the better default. It reads one file per run, so check each child of an index separately.

If XML is overkill

Google also accepts two simpler formats. A text sitemap is a UTF-8 file with a .txt extension and one full URL per line, with nothing else in it. RSS 2.0 and Atom 1.0 feeds work too, though a feed usually carries only your recent posts. Both are fine for a small static site or a blog. XML is still the format to use once you need lastmod dates, an index or more than a handful of pages, and it is the one a sitemap validator is built to check.

Where to put it

Serve the file from the site root, such as /sitemap.xml, and add a line to robots.txt:

Sitemap: https://example.com/sitemap.xml

That line works anywhere in robots.txt and can appear more than once. Then submit the same address in Search Console to see whether Google processed it.

Frequently asked questions

Do I need changefreq and priority in my sitemap?

No. They are optional under the protocol, and Google's documentation says it ignores both.

Can a sitemap list URLs from a subdomain?

Not under the sitemaps.org rules. A sitemap lists URLs on its own protocol and host, and subdomains count as different hosts.

Sources

  1. Sitemaps XML formatsitemaps.org
  2. XML Sitemap Validatorseogeoaeo.ai
  3. Build and submit a sitemapGoogle Search Central
  4. xmllintlibxml2

Add ClaudeGPT Si as a preferred source on Google