From the sitemaps.org protocol, in our words. The namespace of every element here is
http://www.sitemaps.org/schemas/sitemap/0.9, declared on the root.
A sitemap: urlset
| Element | Required | What it holds |
|---|---|---|
urlset | root | The root of a sitemap. It declares the namespace, and the namespaces of any extensions used. |
url | one for each page | The parent of the entry for a page. |
loc | yes | The address of the page: it begins with the protocol (http or https), and has fewer than 2,048 characters. It carries a trailing slash if the server needs one. The address is URL-escaped (RFC 3986), then entity-escaped for XML. |
lastmod | no | When the page last changed, in W3C Datetime format. A date alone, 2024-02-29, is allowed; with a time it has a zone, 2024-02-29T10:30:00+01:00. It is the page’s date, not the date the sitemap was made. Google says it uses the value when it is consistently and verifiably accurate. |
changefreq | no | A hint of how often the page changes: always, hourly, daily, weekly, monthly, yearly or never. Google says it ignores the value. |
priority | no | How important the page is compared with the others on the same site, 0.0 to 1.0; the default is 0.5. Google says it ignores the value. |
A sitemap index: sitemapindex
| Element | Required | What it holds |
|---|---|---|
sitemapindex | root | The root of an index. |
sitemap | one for each file | The entry for a sitemap file. |
loc | yes | The address of the sitemap file. It must be on the same site as the index. |
lastmod | no | When that sitemap file last changed (not when its pages did), so a crawler can fetch only the sitemaps that changed. |
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>https://example.com/sitemap-1.xml.gz</loc>
<lastmod>2024-02-29T10:30:00+00:00</lastmod>
</sitemap>
</sitemapindex>
Escaping
Every value is entity-escaped, as XML requires: & for &, ' for
', " for ", > for > and
< for <. A bare & in an address makes the file not well-formed XML,
and the viewer’s XML reader says so. The sitemaps.org example turns a ü into %C3%BC first, and
then escapes the & of the query string.