XML sitemap example: a minimal file, an index and the common mistakes
Copyable sitemap and sitemap index markup, explained line by line, with a table of the errors that break it.
By ClaudeGPT Si Newsroom, Editorial team
3 min read
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.
urlsetis the root and must carry the namespacehttp://www.sitemaps.org/schemas/sitemap/0.9.- Each page gets a
urlelement with oneloc. Those three tags are the only required ones. lastmodis optional and uses W3C Datetime. A plain date such as2026-10-20is 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 & |
| 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:
- Locally, with xmllint and the published schema. sitemaps.org links schemas for both file types, and xmllint's
--schemaoption validates against a W3C XML Schema. This catches structural errors in a build step. - 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.