Image and video sitemaps: when they help and which tags Google reads

By Pablo Murad. Last updated

Image and video sitemaps are extensions of the regular XML sitemap: you add extra tags inside each <url> to describe the images or videos on that page. They are worth it when the media is hard for a crawler to find on its own. For an image, Google reads one tag, <image:loc>. For a video, it needs a thumbnail, a title, a description and a link to the file or the player.

When it is worth the effort

  • Images that a crawler would not find in the HTML, for example images that a script loads or that sit behind a gallery.
  • Videos you want in Google's video results, mainly when the page does not make the video obvious or when you want to provide the metadata yourself.
  • A site where images or video are the product: stock photos, a portfolio, a course platform.

If your pages use plain <img> tags and standard embeds, Google usually finds the media without help. Search Console accepts these sitemaps but its Sitemaps report does not currently show data for the image and video extensions. Extensions can live in your main sitemap: you do not need a separate file.

Image sitemap

Declare the image namespace in the root element and list each image under the page that shows it. A page can have up to 1,000 images. Images may be hosted on another domain, such as a CDN, as long as both domains are verified in Search Console and robots.txt does not block them. See Google's image sitemap documentation.

<?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">
  <url>
    <loc>https://www.example.com/sample-page</loc>
    <image:image>
      <image:loc>https://www.example.com/images/photo-1.jpg</image:loc>
    </image:image>
    <image:image>
      <image:loc>https://www.example.com/images/photo-2.jpg</image:loc>
    </image:image>
  </url>
</urlset>

Google removed <image:caption>, <image:title>, <image:geo_location> and <image:license> from its documentation. Leave them out. To describe an image, use descriptive alt text and surrounding text on the page.

Video sitemap

Declare the video namespace and add a <video:video> block per video. These are the tags to fill in first, per Google's video sitemap documentation:

Main video sitemap tags and whether they are required
TagRequiredWhat it holds
<video:thumbnail_loc>YesURL of the thumbnail image.
<video:title>YesThe video title.
<video:description>YesA description of the video, up to 2,048 characters.
<video:content_loc> or <video:player_loc>One of the twoThe video file, or the player for it. Each must differ from the page URL in <loc>. Google prefers content_loc when you have it; for iframe players such as YouTube or Vimeo, use player_loc.
<video:duration>NoLength in seconds, from 1 to 28,800 (8 hours).
<video:publication_date>NoWhen the video was published, in W3C format.
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
  <url>
    <loc>https://www.example.com/videos/demo</loc>
    <video:video>
      <video:thumbnail_loc>https://www.example.com/thumbs/demo.jpg</video:thumbnail_loc>
      <video:title>Product demo</video:title>
      <video:description>A three-minute walkthrough of the dashboard.</video:description>
      <video:content_loc>https://www.example.com/media/demo.mp4</video:content_loc>
      <video:duration>180</video:duration>
    </video:video>
  </url>
</urlset>

The video file and the player must be crawlable: not blocked by robots.txt, not behind a login. Google also documents optional tags such as rating, view count, family friendly, restriction and tags.

Deprecated tags

Google lists these video tags as deprecated: <video:category>, <video:gallery_loc>, <video:price>, <video:tvshow>, and the autoplay and allow_embed attributes of <video:player_loc>. Old generators and plugins still write them. They do no harm, but they do nothing either, so remove them when you can.

Check the file

A missing namespace or a malformed tag makes Search Console report an error such as "Incorrect namespace". The free sitemap validator catches those before you submit, and the Search Console errors guide explains the messages for video sitemaps. To send the file, follow the submit guide.

Generate a sitemap that can include the images found on your pages.

Try the free generator