An XML Sitemap lets you share data about the pages on your website with search engines. This can help Google, Bing, AI platforms and other bots identify which pages exist on your website. XML sitemaps can also help establish the canonical version of URLs.

There are also specific XML sitemap formats for news, images, and videos, which are useful if your website uses that type of content. For example, if you regularly share videos on your website, having a video XML sitemap can make it easier for search engines to identify and index those videos.

Example XML Sitemap

The best way to understand an XML sitemap is to walk through the code. Here is an example XML sitemap with a single entry.

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
 <url>
   <loc>https://www.site.com</loc>
   <lastmod>2023-02-15</lastmod>
   <changefreq>monthly</changefreq>
   <priority>1.0</priority>
 </url>
</urlset>

Let’s walk through each tag:

  • <urlset>: An XML sitemap’s entries are contained in a <urlset> tag. Each URL listed in the XML sitemap is nested within this <urlset> tag. The <urlset> tag has one attribute, specifying a namespace. The namespace provides instructions to bots about how they should read this file. The XML sitemap file is not valid without that namespace.
  • <url>: This tag opens a new block of information about a specific URL and </url> closes that block of information. All the tags nested within the <url> tag share information about one particular page on the website.
  • <loc>: This is the only required element and it contains the page’s URL. This should present the canonical version of the URL.
  • <lastmod>: An optional tag, <lastmod> indicates the date the page was last modified. While this might help Google determine the date the page was last updated, Google uses other methods to determine the last update date.
  • <changefreq>: Also an optional tag that is not used by Google, <changefreq> states how frequently the page changes. It can be set to always, hourly, daily, weekly, monthly, yearly, or never. If used, make sure it accurately reflects how often the page will be updated.
  • <priority>: This tag declares the stated priority of a given page relative to other pages on the website. It is optional and not used by Google. It can be set to a range from 0.0 to 1.0, with 1.0 indicating a higher priority page. The default priority is 0.5.

Note: Bing’s developer notes seem to suggest they use <changefreq> and <priority>. However, Google ignores priority and changefreq entries. As a result, I recommend including <loc> in the XML sitemap for simplicity and omitting the other tags.

Image XML Sitemap

Images contained on a page can also be listed in the XML sitemap. This is nested within the <url> tag.

Information about the image is contained within the <image:image> tag and within that tag, the image URL is stated in the <image:loc> tag. Other image tags (caption, title, license and geo_location) have been deprecated by Google.

For example, here is the XML sitemap entry for a page with two images:

<url>
   <loc>https://www.elementive.com/about-elementive/</loc>
   <image:image>
     <image:loc>https://www.elementive.com/data/uploads/Matthew-Edgar.jpg</image:loc>
   </image:image>
   <image:image>
     <image:loc>https://www.elementive.com/data/uploads/Andrea-Streff.jpg</image:loc>
   </image:image>
</url>

In order to list URLs in your website’s main XML sitemap, you need to specify an additional namespace to indicate that image data is contained in the XML sitemap.

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">

Video XML Sitemap

Similar to images, videos can also be listed on an XML sitemap. This should list any video contained on a specific page in that page’s <url> entry within the sitemap. Videos are listed inside a <video:video> tag.

Google requires that specific data be provided about each video:

  • thumbnail (<video:thumbnail_loc>)
  • title (<video:title>)
  • description (<video:description>)

A link to the video is also required. You can either link to the video itself using the <video:content_loc> tag or the video player using the <video:player_loc> tag. You do not need to include both of these tags.

For example, here is an example sitemap entry with information provided about a video contained on the example page:

<url>
    <loc>https://www.site.com/some-page/</loc>
    <video:video>
      <video:content_loc>https://www.site.com/video/myvideo.mp4</video:loc>
      <vide:thumbnail_loc>https://www.site.com/video/myvideo_thumb.jpg</video:thumbnail_loc>
      <video:title>A Great Video</video:title>
      <video:description>Quick summary of video</video:description>
    </video:video>
</url>

As with an image, a specific namespace is required when listing videos.

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">

URLs to Include in the XML Sitemap

The biggest mistake made when building an XML sitemap file is including pages you don’t want Google to crawl, index, or rank. This includes:

  • Error URLs (pages that return a 404, 410, or a 5xx error)
  • Redirected URLs
  • URLs containing low-quality content
  • Duplicate content
  • URLs that have a noindex tag
  • URLs that are blocked from crawling (either in the robots.txt file or via a meta tag)
  • Non-canonical versions of URLs (for example, don’t list http:// URLs when your website forces https://)

You want to regularly prune your XML sitemap file to check for these types of pages and remove these pages from your XML sitemap. As much as possible, these checks should be automated. For example, when a page is deleted from the website, it should automatically be removed from the XML sitemap.

By keeping your XML sitemap free of these types of issues, Google will more regularly crawl and rely on the XML sitemap to discover pages contained on your website.

Submit XML Sitemap In Google Search Console

After creating the XML sitemap, you want to tell Google and Bing about your new sitemap. The easiest way is to submit your XML sitemap directly to Google and Bing via Google Search Console and Bing Webmaster Tools.

In the Google Search Console sidebar menu, go to the “Index” section and then click on “Sitemaps”.

Sitemaps in Google Search Console

On the Sitemaps page, you will see a form to Add a new sitemap. Enter the URL to your XML sitemap, then click “Submit.” Following this, Google will begin reviewing your XML sitemap.

add xml sitemap in google search console

You can check back to this same page later to see if Google has detected any errors with your XML sitemap. On the main list of XML sitemaps submitted, you’ll see when the sitemap was submitted, when Google last read the sitemap, if Google was successful in reading the XML sitemap, and how many URLs were discovered on the sitemap file.

list of xml sitemaps in google search console

You can click on any of these XML sitemaps to view more details, including any details about errors that exist within this XML sitemap file.

Google Search Console - XML sitemap details

From the details page, you can also click to “See Page Indexing”. This will show you Google Search Console’s Page Indexing report specifically for URLs contained in this XML sitemap file. On this report, you can see any URLs on this XML sitemap that are not indexed due to an error or a warning, including errors, duplicate content, or redirected URLs.

Submit XML Sitemap In Bing Webmaster Tools

In Bing Webmaster Tools, navigate to Sitemaps in the sidebar. After arriving on the sitemap page, click on “Submit Sitemap” in the upper right corner. Click submit. On the form that opens in the modal, enter the URL for your website’s XML sitemap. Once submitted, Bing will then crawl through your XML sitemap. You can check back to this same page later to see if Bing has detected any errors with your XML sitemap.

Upload XML sitemap to Bing

List XML Sitemap on Robots.txt

Another way to notify robots about the website’s XML sitemap is to list the XML sitemap on your robots.txt file. This is not officially supported but can be helpful if you are unable to submit the sitemap to Google Search Console or Bing Webmaster Tools. For example, here is the XML sitemap directive on Elementive’s robots.txt file:

Sitemap: http://www.elementive.com/sitemap.xml

Additional Resources

Need Help?

Want help with your website’s XML sitemap or improving your website’s other technical SEO factors? Contact me today.