Introduction
A sitemap lists the pages of a site so that search engines can find them. The usual file is sitemap.xml at the top
of the site, and the format is the Sitemaps XML protocol of sitemaps.org.
A large site cannot list everything in one file, so a second kind of file, the sitemap index, lists the sitemaps
instead of pages. A sitemap can be gzip-compressed, as sitemap.xml.gz.
Sources, fetched as raw files this session: the protocol page (last updated 21 November 2016), sitemap.xsd and siteindex.xsd, the W3C NOTE-datetime, Google’s pages and Google’s extension schemas (listed on the extensions page). There is one version of the protocol, 0.9 (the namespace); the schemas are dated 2008 and 2009, and the protocol page was updated in 2016. The Google extensions have changed since their 2010 schemas: the pages have dropped elements the schemas keep, and the differences are marked on the extensions page.
Structure
The file is XML in UTF-8. The root is a urlset in the namespace
http://www.sitemaps.org/schemas/sitemap/0.9, with a url for each page. Only loc, the
address, is required; lastmod, changefreq and priority are optional. The
elements page has each one.
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://example.com/</loc>
<lastmod>2024-02-29</lastmod>
<changefreq>weekly</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>https://example.com/about</loc>
</url>
</urlset>
The index has the root sitemapindex, and a sitemap with a loc and an optional
lastmod for each file it lists. A sitemap may carry extensions
for images, video, news and the language versions of a page, each in its own namespace. The
limits are 50,000 addresses and 50 MB (52,428,800 bytes) for one file, before compression.
The schema fixes the order inside a url: loc, lastmod, changefreq,
priority, then elements from other namespaces.
In the explorer
Drop sitemap.xml, sitemap_index.xml or a similarly named file on the explorer. If its root is
urlset or sitemapindex in the sitemaps.org namespace it opens as a sitemap: the XML tree, a
table of every URL with its dates, frequency, priority and extensions, a summary (the number of addresses, the hosts, the
extensions in use and the range of last-modified dates) and a list of every rule that is broken, each with its line and
column. An index shows the sitemaps it lists, by address; the explorer does not fetch them. A
sitemap.xml.gz opens through the gzip viewer, and the file inside it as a sitemap.
The options bar has a Sitemap address box. Give the address the sitemap is served at and every URL is checked against the protocol’s rule that it must use the sitemap’s protocol, host and port and lie in its directory. Any other file with such a name (an RSS feed, a page of text, an XML file in another namespace) opens as XML as it always did.
The Text tab is the XML highlighting with the sitemap’s meaning laid over it, following each element’s namespace (any
prefix works). The sitemaps.org elements are tags; the elements of the image, video and news extensions and
xhtml:link are blue. The text of loc and the other address elements is a string, a date in
lastmod (W3C Datetime) or a priority from 0.0 to 1.0 is a number, a changefreq is a keyword,
and yes or no in the video elements is a literal. Red with a wavy underline marks what the protocol does not allow: an
address that is not absolute http or https, a date that is not W3C Datetime, a
changefreq outside the seven words, a priority outside 0.0 to 1.0, and an element of the sitemaps.org namespace that the protocol does not define.
The examples on these pages use the same colours.
Feeds as sitemaps
Protocol page: besides the XML format, an RSS 2.0 or Atom 0.3 or 1.0 feed can be given instead. The address of each page is the link field, and its last modification is the pubDate of an RSS item or the updated date of an Atom entry (optional). A feed may list only recent pages, so it may not cover the whole site, and it should sit in the highest-level directory to be crawled. Google’s build page says it accepts RSS 2.0 and Atom 1.0 (it does not name Atom 0.3), and mRSS for video information (see video); a feed gives no image or news information. All tag values are entity-escaped. A sitemap index may list a feed (protocol: its loc “can be a Sitemap, an Atom file, RSS file or a simple text file”).
Text sitemaps
A sitemap may also be a plain text file, in UTF-8, with one URL on each line, fully specified including the http (protocol page), and nothing else: no header or footer, no comments, no
dates, no URL with an embedded new line. The limits are the same, 50,000 addresses and 50 MB (52,428,800 bytes); a longer list is split into several files. The file may be gzip-compressed and may have any name, and the URLs follow RFC 3986 and RFC 3987; it is uploaded to the highest-level directory to be crawled and lists no URL from a higher-level directory. Google’s build page asks for a .txt extension and says the format can only list HTML and other indexable text pages. A file named like a sitemap
(sitemap.txt, sitemap-1.txt, post-sitemap.txt) opens as a text sitemap when every line that is not blank is an
absolute http or https address of fewer than 2,048 characters (the 2,048 limit is the viewer’s borrowing from the XML loc rule, not stated for text files); any other such file opens as plain text.
The Text tab shows the protocol and host in the type colour, the path as a string and the query or fragment as a
variable. A line that is not an address is red with a wavy underline, and an address after the 50,000th, or after the first 50 MB, is grey (the
protocol sets the limits and does not say what a crawler does past them). The Overview counts the addresses, the hosts and
the lines that are not addresses.
https://example.com/
https://example.com/about
https://example.com/products?id=7
Not described
Known, not yet covered
- Viewer: RSS and Atom feeds used as sitemaps are not read as sitemaps; they open as XML. A text sitemap has no viewer beyond its colours and counts (no tree, no per-address checks of host and directory).
- Viewer: only the elements of the extensions listed on the extensions page have their text read by kind; an element Google adds later is shown as a tag in the extension’s colour with its text plain. Elements of the sitemaps.org namespace that the protocol does not define are flagged.
- Viewer: the order of the elements inside a
url, whichsitemap.xsdfixes (and inside asitemapof an index, and insidevideo:videoandnews:news), is not checked. The elements that Google’s 2010 schemas still define and its pages removed (the image caption, geo_location, title and license; video category, gallery_loc, price, tvshow, content_segment_loc, id and the player_loc attributes; news access, genres, keywords and stock_tickers) are described on the extensions page, but the viewer may not read them by kind. - Viewer: the Google mobile extension is recognised by its namespace only.
- Viewer: whether an address returns a page, and whether alternate-language links point back at each other, cannot be checked from one file.
Unknown
- Reference: whether a sitemap index may list another index. Not stated in the sitemaps.org protocol page (which lists a sitemap, Atom, RSS or text file), in siteindex.xsd, or in Google’s index and overview pages (four sources read); the viewer only notes an address that looks like an index.
- Reference: the mobile extension (
sitemap-mobile/1.0) and the older Google namespacehttp://www.google.com/schemas/sitemap/0.84: no page or schema read documents either. The viewer recognises the first by name and does not accept the second as a sitemap.
Links
Reference
- sitemaps.org protocol – the format, its tags, the limits and the escaping rules
- Google: build and submit a sitemap – the formats Google reads, its limits, and the tags it ignores
- Google: image sitemaps – the image extension
- Google: video sitemaps – the video extension
- Google: news sitemaps – the news extension
- Google: localized versions of a page – alternate-language links in a sitemap