Sitemap

A sitemap is a form of SEO that allows for Search Engines to discover all pages of a website more efficiently

Formats

Best practice โ€” Machine readable sitemap.xml + Human readable sitemap.html

No sitemap Website pages well linked Appropriate for small sites
HTML sitemap An HTML page with all of the links Human readable format
XML sitemap sitemap.xml Recommended
Feed sitemap rss.xml ยท mrss.xml ยท atom.xml Limited ยท Convenient format
Text sitemap sitemap.txt Limited ยท Simplest format

Google Search Central โ€” Sitemap ยท Supported formats

No sitemap

A website well linked is equivalent to having a sitemap

It must be possible to navigate to every public page on your website from index.html

index.html
<a href='/other-page'>Link to other page</a>

Google Search Central โ€” Do I need a sitemap?

HTML sitemap

An HTML sitemap is a page dedicated to linking every page on your website

  • It is equivalent to having No sitemap
  • It is not a Sitemap protocol standard
  • It is human readable

Your HTML sitemap page must be linked from index.html

sitemap.html
8 collapsed lines
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sitemap</title>
</head>
<body>
<ul>
<li><a href='/'>Home page</a></li>
<li><a href='/blog'>Blog page</a></li>
<li><a href='/about'>About page</a></li>
</ul>
2 collapsed lines
</body>
</html>

XML Sitemap

sitemap.xml is the standard Machine readable format

sitemap.xml must be specified in robots.txt or submited in Google Search Console

sitemap.xml
<?xml version="1.0" encoding="UTF-8"?>
โ€‰

Every xml file starts with the XML declaration

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">

A Sitemap is defined by the <urlset> element

  • The version is 0.9 and constant since 2009
<url>
โ€‰

The <urlset> consists of <url> entries

<loc>https://stephcraft.net/blog</loc>
โ€‰

The url of the page

<lastmod>2020-01-01</lastmod>
โ€‰

The last modified date of the page

  • Must be in the format YYYY-MM-DD

This attribute is optional

Deprecated attributes โ€” 2 collapsed lines
<changefreq>monthly</changefreq>

The expected frequency of updates for this page

  • always โ€” dynamic or SSR/CSR pages
  • hourly
  • daily
  • weekly
  • monthly
  • yearly
  • never

This attribute is optional
This attribute is deprecated ยท use <lastmod> instead

<priority>0.8</priority>

The priority of this page relative to other pages on the website

  • Must be between 0 and 1
  • Defaults to 0.5

This attribute is optional
This attribute is deprecated

</url>
Example โ€” 4 collapsed lines
<url>
<loc>https://stephcraft.net/docs/sitemap</loc>
<lastmod>2020-01-01</lastmod>
</url>
...
</urlset>

Sitemaps.org โ€” Protocol

XML Sitemap Index

sitemap.xml can be split into multiple files by defining it as a Sitemap Index

sitemap.xml
<?xml version="1.0" encoding="UTF-8"?>
โ€‰

Every xml file starts with the XML declaration

<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">

A Sitemap Index is defined by the <sitemapindex> element

  • The version is 0.9 and constant since 2009
<sitemap>

The <sitemapindex> consists of <sitemap> entries

<loc>https://stephcraft.net/sitemap-blog.xml</loc>
โ€‰

The url of the Sitemap

<lastmod>2020-01-01</lastmod>
โ€‰

The last modified date of the Sitemap

  • Must be in the format YYYY-MM-DD

This attribute is optional

</sitemap>
Example โ€” 4 collapsed lines
<sitemap>
<loc>https://stephcraft.net/sitemap-core.xml</loc>
<lastmod>2020-01-01</lastmod>
</sitemap>
...
</sitemapindex>

Sitemaps.org โ€” Protocol ยท Index
Google Search Central โ€” Sitemap Index

Localization Sitemap Extension

sitemap.xml can specify translated page variants

sitemap.xml
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
โ€‰

Apply the Localization sitemap extension

<url>
<loc>https://stephcraft.net/blog</loc>
<lastmod>2020-01-01</lastmod>
<xhtml:link

Add <xhtml:link> entries for each translated page variant

rel="alternate"
โ€‰

The relationship must be set to "alternate"

hreflang="en"

Specify the language here

  • Must be in en or en-US format
  • Use x-default for a fallback page
href="https://stephcraft.net/en/blog"

The url of the translated page variant

/>
Example โ€” 5 collapsed lines
<xhtml:link
rel="alternate"
hreflang="fr"
href="https://stephcraft.net/fr/blog"
/>
...
</url>
...
</urlset>

The Localization Sitemap Extension is developed by W3C

Google Search Central โ€” Localized Sitemap

Media Sitemap Extensions

sitemap.xml can specify Images, Videos and News articles

sitemap.xml
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
โ€‰

Apply the Image sitemap extension

  • The version is 1.1 and constant since 2010
  • Developed by Google
xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"
โ€‰

Apply the Video sitemap extension

  • The version is 1.1 and constant since 2010
  • Developed by Google
xmlns:news="http://www.google.com/schemas/sitemap-news/0.9">

Apply the News sitemap extension

  • The version is 0.9 and constant since 2006
  • Developed by Google
<url>
<loc>https://stephcraft.net/docs/ai</loc>
<lastmod>2020-01-01</lastmod>
<image:image>
โ€‰

Add <image:image> entries for each Image on the page

<image:loc>https://stephcraft.net/assets/logo.png</image:loc>
โ€‰

The url of the Image

</image:image>
Image Example โ€” 3 collapsed lines
<image:image>
<image:loc>https://stephcraft.net/assets/vibe-code.png</image:loc>
</image:image>
...
<video:video>
โ€‰

Add <video:video> entries for each Video on the page

<video:thumbnail_loc>https://stephcraft.net/thumbs/0.png</video:thumbnail_loc>
โ€‰

The url of the Thumbnail image

<video:title>Zombiecraft trailer</video:title>
โ€‰

The title of the video

<video:description>An awesome video</video:description>
โ€‰

The descriptiom of the video

<video:content_loc>http://streamserver.stephcraft.net/video0.mp4</video:content_loc>
โ€‰

The url of the Video

Optional โ€” 16 collapsed lines
<video:player_loc>https://stephcraft.net/videoplayer.php?video=0</video:player_loc>

The url of a player for the Video

  • Either <video:content_loc> or <video:player_loc> must be defined
  • When both are defined, <video:player_loc> acts as a fallback
<video:duration>1150</video:duration>

The duration of the video (in seconds)

<video:expiration_date>2020-01-01T19:20:30+08:00</video:expiration_date>
โ€‰

The date after which the video is no longer available

  • Format is YYYY-MM-DD or YYYY-MM-DDThh:mm:ss+TZD
<video:rating>4.2</video:rating>

The rating of the video

  • number between 0.0 and 5.0
<video:view_count>1000000</video:view_count>

The number of times the video has been viewed

<video:publication_date>2020-01-01T19:20:30+08:00</video:publication_date>

The date the video was published

  • Format is YYYY-MM-DD or YYYY-MM-DDThh:mm:ss+TZD
<video:family_friendly>yes</video:family_friendly>
โ€‰

Whether the video is available with SafeSearch

  • yes or no
<video:restriction relationship="allow">IE GB US CA</video:restriction>
โ€‰

Restrictions for the availability of the video in certain countries

  • Country codes in the format US separated by space
  • relationship="allow" allow access for the listed countries
  • relationship="deny" deny access for the listed countries
<video:platform relationship="allow">web tv</video:platform>

Whether to show or hide your video in search results on specified platforms

  • List of keywords separated by space:
    • web Desktop browsers
    • mobile Mobile browsers
    • tv TV browsers
  • relationship="allow" allow access for the listed platforms
  • relationship="deny" deny access for the listed platforms
<video:requires_subscription>yes</video:requires_subscription>
โ€‰

Indicates whether a subscription (either paid or free) is required to view the video

  • yes or no
<video:uploader info="https://stephcraft.net/self">Stephcraft</video:uploader>

The video uploader's name

  • optional โ€” info the url of the uploader (must be in the same domain)
<video:live>no</video:live>

Whether the video is a livestream

  • yes or no
<video:tag>dev</video:tag>
<video:tag>gaming</video:tag>
<video:tag>web</video:tag>
โ€‰

A tag associated with the Video

  • Many <video:tag> can be present
...
</video:video>
Example Video โ€” 6 collapsed lines
<video:video>
<video:thumbnail_loc>https://stephcraft.net/thumbs/0.png</video:thumbnail_loc>
<video:title>Zombiecraft trailer</video:title>
<video:description>An awesome video</video:description>
<video:content_loc>http://streamserver.stephcraft.net/video0.mp4</video:content_loc>
</video:video>
...
<news:news>

Add <news:news> entries for each News on the page

<news:publication>
<news:name>The Example Times</news:name>

The title of the news publisher

<news:language>en</news:language>

The language of the news article

  • Must be in en format
</news:publication>
<news:publication_date>2020-01-01</news:publication_date>
โ€‰

The date the news article was published

  • Format is YYYY-MM-DD or YYYY-MM-DDThh:mm:ss+TZD
<news:title>How Gradle became the #1 buildtool</news:title>
โ€‰

The title of the news article

</news:news>
Example News โ€” 8 collapsed lines
<news:news>
<news:publication>
<news:name>The Example Times</news:name>
<news:language>en</news:language>
</news:publication>
<news:publication_date>2020-01-01</news:publication_date>
<news:title>Why Kotlin is the best programming language</news:title>
</news:news>
...
</url>
...
</urlset>

The Media Sitemap Extensions are developed by Google

  • Image
  • Video
  • News

Google Search Central โ€” Sitemap Extensions

Feed sitemap

This section is currently undocumented
Let @Stephcraft know on Discord you'd like this section Documented
Join Discord

Sitemaps.org โ€” Protocol ยท Syndication feed
Google Search Central โ€” Feed Sitemap
Google Search Central โ€” mRSS Sitemap

Text sitemap

sitemap.txt is the simplest format

sitemap.txt must be specified in robots.txt or submited in Google Search Console

sitemap.txt
https://stephcraft.net/blog
https://stephcraft.net/docs/ai
https://stephcraft.net/docs/sitemap
โ€‰

List each url per line

...

Sitemaps.org โ€” Protocol ยท Text file
Google Search Central โ€” Text Sitemap

Tools

XML Sitemap Generator

Resources

Sitemaps.org
Google Search Central โ€” Sitemaps
Wikipedia โ€” Sitemaps
Wikipedia โ€” Sitemap

Frameworks

Astro Docs โ€” Sitemap
Next.js Docs โ€” Sitemap
TanStack Start Docs โ€” Sitemap

This website is currently available on Desktop only
Let @Stephcraft know on Discord you'd like a Mobile version

Join Discord