An XML sitemap follows a small, fixed vocabulary defined by the Sitemaps.org protocol. Once you can read the tags, there isn't much to it — this is a tag-by-tag reference with real examples, so you can check your own sitemap against it or write one by hand.
The Minimal Valid Sitemap
Every sitemap needs exactly this structure — an <urlset> root element with the correct namespace, and one <url> block per page:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://example.com/</loc>
</url>
<url>
<loc>https://example.com/about</loc>
</url>
</urlset>That's a complete, valid sitemap. <loc> is the only required field inside each <url> block. Everything else is optional.
A Fully-Populated Example
Here's one URL entry using every standard optional tag:
<url> <loc>https://example.com/blog/xml-sitemap-guide</loc> <lastmod>2026-07-08</lastmod> <changefreq>monthly</changefreq> <priority>0.8</priority> </url>
Tag Reference
| Tag | Required? | What it does |
|---|---|---|
| <urlset> | Yes | Root element. Must declare the sitemap namespace — every valid sitemap starts here. |
| <url> | Yes | Wraps one page entry. One per indexable URL. |
| <loc> | Yes | The full, absolute URL — including https:// and the exact canonical form. |
| <lastmod> | Optional | ISO 8601 date. Used by Google to prioritize re-crawling, but only when it reflects a real content change. |
| <changefreq> | Optional | A hint like "daily" or "monthly". Google ignores it; not worth optimizing. |
| <priority> | Optional | A 0.0–1.0 relative-importance hint. Google ignores it too — see best practices below. |
For the full picture on which of these fields actually influence crawling in 2026, see XML sitemap best practices.
The Sitemap Index Format
Once you have more than one sitemap file, a separate format — a sitemap index — lists them. It uses <sitemapindex> and <sitemap> instead of <urlset> and <url> — a common source of confusion:
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>https://example.com/sitemap-pages.xml</loc>
</sitemap>
<sitemap>
<loc>https://example.com/sitemap-posts.xml</loc>
</sitemap>
</sitemapindex>Full guide: what a sitemap index file is and when you need one.
Formatting Mistakes That Get a File Rejected
- Missing or wrong namespace — the
xmlnsattribute on<urlset>must be exactlyhttp://www.sitemaps.org/schemas/sitemap/0.9. A typo here can invalidate the whole file. - Mixing urlset and sitemapindex tags — a file is either a sitemap of pages or an index of sitemaps, never both.
- Unescaped special characters in URLs — a literal
&in a URL must be written as&— raw ampersands break XML parsing. - Wrong content type — serving the file as
text/htmlinstead ofapplication/xmlcauses Search Console to reject it even if the markup itself is valid. - Relative URLs — every
<loc>must be a full absolute URL with protocol and domain, not a path like/about.
Run any sitemap through a validator before submitting — see how to validate a sitemap for four ways to catch these before Google does.
Where This Fits
If you're looking for what a sitemap is and why you need one, start with what is an XML sitemap. This page is the syntax reference to come back to once you're actually writing or debugging one.