How to create a Google video sitemap in Drupal

Please note: This is a service that we provide for our customers. If you're a customer, you don't really need to watch this video. The video is only really intended for fellow Drupalers, it's our way of contributing back where we can... If you would like us to add this to your existing Drupal site, just get in touch to discuss the details of your site...

This video demonstrates how to build a Google video sitemap, whilst using the Embedded Media field Media:YouTube, and JW Player Module for Drupal modules to add the video functionality to the site. That said, I can't see any reason why it couldn't be used for Drupal websites using other image and video modules...

This method was inspired by bensnyder's comment on Drupal and made possible with code from voxpelli. In order to follow this Drupal video you'll need to:

  1. Install Views
  2. (Updated since making video) Install your own player, Google apparently won't index the embeds if you use a direct YouTube URL for the player_loc. I decided to use the JW Player Module for Drupal
  3. Install Views datasource, specifically "Views XML"
  4. You'll need to apply this patch for Views datasource to allow "XML fragments"
  5. Install Views Field View so you can embed the 1st view into the 2nd view
  6. Install Drupal plain views. This removes the mark up around the embedded view.

The video then demonstrates making the two views that are used to create the Google video sitemap. The idea is to build the 1st view to pull the data out that is used within the <video:video> and </video:video> tags. Then build a 2nd view which embeds the 1st view with it's corresponding node path within the <loc> tags, if that makes sense...

Here's a brief description of the two views:

The 1st view:
Basic settings

  • Style "XML data document". With both "Views api mode" and "is XML fragment" selected
  • Items to display: unlimited

Arguments

  • Node: Nid

Fields.

  • Content: Video Image Thumbnail (absolute url to thumbnail and label=video:thumbnail_loc)
  • Node: Title (label=video:title). Max length is 100 characters.
  • Node: Body (label=video:description) Max length is 2048 characters.
  • Content: Video URL to original video (label=video:player_loc, (Updated since making video) Rewrite the output of this field= http://example.com/sites/example.com/files/jwplayermodule/player/player.... )
  • Content: Duration (label=video:duration)
  • Add a "Plain" display for the view.

The 2nd view, available to view here:
Basic settings

  • Style "XML data document". With "Views api mode" selected
  • Items to display: unlimited

Fields.

  • Node: Nid Nid (exclude from display)
  • Node: Path (label=loc)
  • Global: View (label=video:video. I selected my 1st view, display: plain, arguments: [nid].)

Also, worth mentioning is that YouTube block the thumbnails using their "robots.txt" file. So, we're choosing to store all our thumbnails locally, to make sure that our video's get indexed.

If you need a Drupal 7 video sitemap or any other Drupal web development done, please contact me to discuss your requirements.

Post type: 
Drupal version: