XML Sitemap Format: Tags, Rules and Examples
Short answer: an XML sitemap is a UTF-8 file with a <urlset> root element. Inside it, each page gets a <url> block with a <loc> tag holding the full URL. That is all that’s required. <lastmod> is optional and worth adding if it’s accurate. <changefreq> and <priority> are optional too, but Google ignores them. One file holds up to 50,000 URLs and 50 MB uncompressed.
A minimal, valid 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-01</lastmod>
</url>
<url>
<loc>https://example.com/pricing</loc>
<lastmod>2026-09-14T08:00:00+00:00</lastmod>
</url>
</urlset>The first line declares XML and UTF-8. The xmlns value must be exactly http://www.sitemaps.org/schemas/sitemap/0.9. Note it starts with http, not https.
Every tag, and what Google does with it
| Tag | Status | What it holds | |
|---|---|---|---|
<urlset> | Required | Root element. Declares the namespace http://www.sitemaps.org/schemas/sitemap/0.9. | Must be exact, or the file won’t parse as a sitemap. |
<url> | Required | One block per page. | - |
<loc> | Required | Full URL with protocol, under 2,048 characters, same host as the sitemap. | Crawled exactly as written, so list the canonical URL. |
<lastmod> | Optional | Last time the page changed, in W3C Datetime format: 2026-10-13 or 2026-10-13T09:30:00+00:00. | Used only when it is consistently and verifiably accurate. |
<changefreq> | Optional | always, hourly, daily, weekly, monthly, yearly or never. | Ignored. |
<priority> | Optional | 0.0 to 1.0, default 0.5, relative to your other pages only. | Ignored. |
lastmod: the one optional tag worth getting right
Google uses <lastmod> only if it is “consistently and verifiably” accurate. It should change when the main content, structured data or links change, not for a new copyright year. Setting every URL to today’s date teaches search engines to ignore the field. Bing also treats lastmod as a recrawl signal and asks for full dates with time. See our lastmod guide.
Rules the file must follow
- UTF-8 encoding. Google requires it.
- Full URLs.
https://example.com/page, never/page. - Same host and protocol as the sitemap. A sitemap in
/blog/can only list URLs under/blog/, so put yours at the site root. - Escape five characters inside values:
| Character | Write it as |
|---|---|
& | & |
' | ' |
" | " |
> | > |
< | < |
So https://example.com/shop?cat=1&page=2 becomes https://example.com/shop?cat=1&page=2 in the file. A raw & breaks the XML, and search engines then can’t read the file.
- Size: at most 50,000 URLs and 50 MB uncompressed per file. Gzip (
sitemap.xml.gz) is allowed, but the limit counts the uncompressed size.
Sitemap index format
When you have more than one sitemap, list them in an index file. It uses <sitemapindex> and <sitemap> instead of <urlset> and <url>:
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>https://example.com/sitemap-posts.xml</loc>
<lastmod>2026-10-12</lastmod>
</sitemap>
<sitemap>
<loc>https://example.com/sitemap-products.xml</loc>
</sitemap>
</sitemapindex>An index can list up to 50,000 sitemaps, all on the same site. It can’t list another index: Google reports that as “Nested sitemap indexes”. More in our sitemap index guide.
Extensions for images, video, news and languages
Google supports extra namespaces on top of the base format. You declare each one on <urlset> and add its tags inside a <url>:
- Images:
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"with<image:image><image:loc>. See our image sitemap guide. - Video:
http://www.google.com/schemas/sitemap-video/1.1 - News:
http://www.google.com/schemas/sitemap-news/0.9 - Language versions:
xmlns:xhtml="http://www.w3.org/1999/xhtml"with<xhtml:link rel="alternate" hreflang="...">.
Other formats search engines accept
XML is the most common, but Google also reads RSS 2.0 and Atom 1.0 feeds, and plain text files with one URL per line. Bing accepts the same plus Atom 0.3. A text sitemap is the simplest possible format, but it can’t carry lastmod or extensions.
Check your format
The free sitemap checker fetches and parses your sitemap, and tests 30 of its URLs live for errors, redirects, noindex and canonical problems. Need a sitemap first? The XML sitemap generator writes a valid file from your live site, and our sitemap examples show complete files for common site types.
Frequently asked questions
What are the limits of an XML sitemap?
One sitemap can list up to 50,000 URLs and be up to 50 MB uncompressed. You can gzip it, but the limit applies to the uncompressed size. A sitemap index can list up to 50,000 sitemaps.
What date format does lastmod use?
W3C Datetime. A date alone (2026-10-13) is valid, and so is a date with time and time zone (2026-10-13T09:30:00+00:00). It should be the date the page content changed, not the date the sitemap was built.
Does Google use priority and changefreq?
No. Google’s sitemap docs say it ignores both values. Bing says the same. Spend the effort on an accurate lastmod instead.
How do I open an XML sitemap?
Open its URL in a browser, such as example.com/sitemap.xml. Most browsers show the XML tree. Some sites add a stylesheet so the sitemap looks like a table; the file underneath is still XML.
Are other sitemap formats allowed?
Yes. Google also accepts RSS 2.0 and Atom 1.0 feeds and plain text files with one URL per line. Text sitemaps can only list page URLs.