From the sitemaps.org protocol (page last updated 21 November 2016),
the schema sitemap.xsd (last modified 2008-03-26)
and the schema siteindex.xsd (last modified
2009-04-08), all fetched as raw files and read in full, in our words. The namespace of every element here is
http://www.sitemaps.org/schemas/sitemap/0.9, declared on the root. Where the protocol text and the schema
differ, both are given and the difference is marked as ours.
Rules that hold for the whole file. The file is UTF-8, and every value is entity-escaped (see below). A sitemap
begins with urlset and ends with its closing tag, names the namespace on it, has a url for each
URL, and has a loc in each url; every other tag is optional, and support for the optional ones
varies between search engines (protocol text). All the URLs in one sitemap come from a single host. Both schemas are in
the namespace above with elementFormDefault="qualified", so every element is in the namespace.
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. The schema allows any number (zero or more) of elements from other namespaces before the first url, and at least one url. The schema comment says it holds up to 50,000 of them (the limit is stated in the protocol text; the schema does not enforce it). |
url | one or more, one for each page | The parent of the entry for a page. The schema fixes the order of its children: loc, then lastmod, then changefreq, then priority, then any number of elements from other namespaces (extensions). Each of the four is allowed once. |
loc | yes | The address of the page: it begins with the protocol (such as http) and ends with a trailing slash if the server needs one. Protocol text: the value must be less than 2,048 characters. Schema (tLoc, an xsd:anyURI): a length of 12 to 2,048 characters inclusive, and the comment says the URI conforms to RFC 2396. The protocol text says URLs must be URL-escaped and follow RFC 3986 (URIs) and RFC 3987 (IRIs), and then entity-escaped for XML. Our reading: an address of exactly 2,048 characters is accepted by the schema and excluded by the text. |
lastmod | no | When the page last changed, in W3C Datetime format, which the protocol says may omit the time and use YYYY-MM-DD. It is the date the linked page was last modified, not the date the sitemap was made. It is separate from the If-Modified-Since (304) header, and a search engine may use the two differently. The six W3C Datetime levels are listed below. Schema (tLastmod): a union of xsd:date and xsd:dateTime, with comments giving 2005-05-10 and 2005-05-10T17:33:30+08:00 as examples. Google says it uses the value when it is consistently and verifiably accurate, and that it should reflect the last significant update (an update to the copyright date is not). |
changefreq | no | A hint of how often the page changes, “not a command”. The schema type is an xsd:string enumeration of exactly these lower-case words: always (a page that changes each time it is accessed), hourly, daily, weekly, monthly, yearly and never (archived URLs). A crawler may crawl “hourly” pages less often, “yearly” pages more often, and may crawl “never” pages now and then. 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 schema type is an xsd:decimal from 0.0 to 1.0 inclusive); the default is 0.5. It does not affect how the pages compare with other sites’ pages, and giving every URL a high value does not help. Google says it ignores the value. |
W3C Datetime, the levels of the NOTE
The lastmod value refers to the W3C NOTE-datetime profile of ISO 8601 (read in full in this session). Each level must have exactly the components shown, with exactly this punctuation, the T literal:
YYYY(1997);YYYY-MM(1997-07);YYYY-MM-DD(1997-07-16);YYYY-MM-DDThh:mmTZD(1997-07-16T19:20+01:00);YYYY-MM-DDThh:mm:ssTZD(1997-07-16T19:20:30+01:00);YYYY-MM-DDThh:mm:ss.sTZD(1997-07-16T19:20:30.45+01:00), with one or more digits for the fraction; the NOTE leaves the number of digits to the adopting standard.
Hour 00 to 23, minute and second 00 to 59, no am/pm, the year always four digits. TZD is Z (UTC) or +hh:mm or -hh:mm (ahead of or behind UTC). The schema names only the types xsd:date and xsd:dateTime. From XML Schema Part 2: Datatypes (W3C Recommendation, sections 3.2.7.1 and 3.2.9.1, read this session): dateTime is yyyy-mm-ddThh:mm:ss with optional .s fraction and an optional time zone, and its seconds are required; date is yyyy-mm-dd with an optional time zone; the hour 24 is allowed when minutes and seconds are zero. So the schema rejects a lone year, a year and month, and a time without seconds, which the NOTE allows, and it accepts a time or date with no zone, which the NOTE does not (a NOTE time level always ends in a TZD), and a date followed by a zone (2005-05-10Z), which the NOTE does not list. The sitemaps.org text points at the NOTE (the schema is the stricter on precision and the looser on the zone); the viewer follows the NOTE.
A sitemap index: sitemapindex
| Element | Required | What it holds |
|---|---|---|
sitemapindex | root | The root of an index, in the same namespace. It begins with its opening tag and ends with the closing one. It lists at most 50,000 sitemaps and is at most 50 MB (52,428,800 bytes), and may be gzip-compressed. A site may have more than one index. The schema allows elements from other namespaces before the first sitemap. |
sitemap | one or more, one for each file | The entry for a sitemap file. Schema order: loc, then lastmod, then any number of elements from other namespaces. |
loc | yes | The location of the sitemap. Protocol text: it can be a sitemap, an Atom file, an RSS file or a simple text file. Schema (tLocSitemap): the same 12 to 2,048 character xsd:anyURI as in a sitemap. A sitemap index can only list sitemaps found on the same site as the index (http://www.yoursite.com/sitemap_index.xml may list sitemaps on http://www.yoursite.com, not on http://www.example.com or http://yourhost.yoursite.com). Google adds that the listed sitemaps must be in the index’s directory or deeper, and that this is waived with cross-site submission. |
lastmod | no | When the sitemap file last changed (not when any page listed in it did), in W3C Datetime format (the schema type is the same xsd:date or xsd:dateTime union). With it a crawler can fetch only the sitemaps changed since a date, for rapid discovery on very large sites. |
Sources for this table: the protocol text, siteindex.xsd, and Google’s “Manage your sitemaps with a sitemap index file” page (last updated 2025-12-10), which also says an index is limited to 50,000 loc tags and that up to 500 index files can be submitted for each site in a Search Console account. Whether an index may list another index is not stated in any of them; see Not described on the overview.
<?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.
The protocol’s own examples of one address: http://www.example.com/ümlat.php&q=name as ISO-8859-1 URL-escaped is
http://www.example.com/%FCmlat.php&q=name, as UTF-8 URL-escaped is
http://www.example.com/%C3%BCmlat.php&q=name, and entity-escaped in the file it is
http://www.example.com/%C3%BCmlat.php&q=name. The protocol says that if a script or tool makes the URLs,
this is usually done already.
Where a sitemap may point
All of this is from the protocol page and Google’s build page, read as raw text.
- The location of a sitemap decides which URLs it may list: http://example.com/catalog/sitemap.xml may list URLs starting with http://example.com/catalog/ and not http://example.com/images/ (protocol text). Invalid URLs “are dropped from further consideration”.
- All URLs use the same protocol and sit on the same host as the sitemap: https://example.com/catalog/page1.php is not valid in an http sitemap, and a sitemap on www.example.com cannot list subdomain.example.com. If the sitemap is at a path with a port (http://www.example.com:100/sitemap.xml) every URL starts with that port.
- The protocol strongly recommends putting the sitemap at the root of the server.
- Cross submission (a sitemap on one host listing URLs of others): the sitemaps.org page makes it work by having the other host’s robots.txt contain
Sitemap: http://www.sitemaphost.com/sitemap-host1.xml, and then each target sitemap lists the URLs of the host that points to it only. Google’s build page describes the same two ways (Search Console with verified ownership, or robots.txt) and says a single sitemap may include URLs of several verified sites. - Google (build page): unless the sitemap is submitted through Search Console, a sitemap affects only descendants of its parent directory.
Validating, extending, announcing
The two schemas above are the validators. To validate, a file adds the headers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" and
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" on urlset (or
.../siteindex.xsd on sitemapindex). The protocol is extended by declaring your own namespace on the root, xmlns:example="http://www.example.com/schemas/example_schema", and using
example:example_tag inside url; the schemas’ xsd:any namespace="##other" with processContents="strict" allows such elements from any other namespace (the meaning of processContents="strict" is defined by the XML Schema specification, not read here).
A search engine learns of a sitemap in one of three ways, all described on the protocol page: its submission interface; a line Sitemap: http://www.example.com/sitemap.xml in robots.txt (independent of any user-agent line, may repeat, and for an index you list only the index); or an HTTP request <searchengine_URL>/ping?sitemap=sitemap_url with the address URL-encoded, where HTTP 200 only means the engine received it. Google’s build page lists Search Console, its API, the robots.txt line and WebSub for Atom or RSS, and does not mention the ping form; whether an engine still accepts a ping was not checked. To keep content out of search, the protocol points to robots.txt and the robots meta tag.