All posts
SEO Basics

XML Sitemap Format Explained: Syntax, Tags & Real Examples

A tag-by-tag reference for XML sitemap syntax — the minimal valid example, every optional field, the sitemap index format, and the formatting mistakes that get a whole file rejected.

July 8, 2026·5 min read

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

TagRequired?What it does
<urlset>YesRoot element. Must declare the sitemap namespace — every valid sitemap starts here.
<url>YesWraps one page entry. One per indexable URL.
<loc>YesThe full, absolute URL — including https:// and the exact canonical form.
<lastmod>OptionalISO 8601 date. Used by Google to prioritize re-crawling, but only when it reflects a real content change.
<changefreq>OptionalA hint like "daily" or "monthly". Google ignores it; not worth optimizing.
<priority>OptionalA 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 xmlns attribute on <urlset> must be exactly http://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 &amp; — raw ampersands break XML parsing.
  • Wrong content type — serving the file as text/html instead of application/xml causes 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.

Try it free

Generate and check your sitemap in minutes

Crawl up to 2,000 URLs for free — no credit card required. See your health score and download your sitemap XML instantly.

Generate your sitemap →