Internet search engines provide end-users a quick and easy to use way to get access to information available on the Internet. As more and more Internet content is multimedia, you need to ensure that your content is properly indexed by the search engines so that users can discover it. This article will provide an overview of how to enable your video content to be SEO enabled and indexed by the various search engines (Google, Yahoo, Microsoft).
Internet search engines provide end-users a quick and easy to use way to get access to information available on the Internet. As more and more Internet content is multimedia, you need to ensure that your content is properly indexed by the search engines so that users can discover it. This article will provide an overview of how to enable your video content to be SEO enabled and indexed by the various search engines (Google, Yahoo, Microsoft).
There is a standard document, called a sitemap, that search engine indexers look for when examining your site. This document concisely tells the search engines what content is exposed on your site, the metadata for that content, and where that content is located on your site. A sitemap is an XML file that follows a standard specification.
Note that a simple MRSS feed may work also, if you don't have the means to produce a video sitemap.
There are two different flavors of sitemaps that you can (and should) create:
Note that both of these sitemaps index the metadata about your video content and provide links to end-users. The difference is where the metadata that is indexed is obtained from and how the content is surfaced in search results.
A proper SEO strategy for your video content will include creating both a standard sitemaps as well as a video sitemap. From a priority perspective, you want to create a standard Sitemap first and then a Video Sitemap. Using the Video Cloud Media API, you can create your sitemaps automatically, rather than compiling them by hand. The examples in this article use Ruby; the Resources section will point you to approaches that use Python and Java.
Sitemaps follow the sitemap specification that is defined here: www.sitemaps.org. The purpose of the sitemap file is to provide a list of URLs on your site to the search engines. The only other information associated with a URL is when the page was last modified and how frequently the page changes. Note, there is no metadata about your content in this index. Because the sitemap is page-centric, we need to create a model where each video in your library will have a unique page, or URL, associated with it. This can be accomplished by having a single page whose behavior and content can be dynamically changed by passing in different query parameters to the page. For example, if you have a URL like http://www.example.com/video.html?videoId=123, you would have the video.html page look for the videoId query parameter (videoId=123) and modify the contents of the page returned to the browser to contain information about the video with id 123. This would be done on the server-side of your application where the page would look for the ID and then use the Video Cloud Media APIs to fetch metadata about the video and write it into the page.
For the purposes of this article, we assume that there is a single landing page on your site which can be used to play back all video content for your site. Different query parameters will be passed to the page to tell the page what video to play back and what video to surface metadata for. For example, let's say you have a page that displays the contents of an entire playlist and queues up a specific video in a player. You tell the page what playlist to display metadata for via a bclid query parameter and what video to surface in a player via the bctid parameter. Thus, what we want to do is create a URL for every unique playlist and video id combination.
Here is an example of sitemap that will be created:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>http://www.example.com/video?bclid=345&bctid=123</loc>
<lastmod>2008-01-01</lastmod>
<changefreq>weekly</changefreq>
</url>
<url>
<loc>http://www.example.com/video?bclid=12&bctid=544</loc>
<lastmod>2008-03-01</lastmod>
<changefreq>weekly</changefreq>
</url>
</urlset>
To create a sitemap file, you can use the attached script. This script walks through the playlists in the Video Cloud account and, for each playlist, walks through its contained videos. For each playlist and video combination, the script creates an entry in the sitemap supplying a unique URL to the playlist/video combination. Once you've created a sitemap file for your site, place the resulting sitemap.xml file in the root directory of your webserver. For example, if your domain is www.example.com, the sitemap file would be available at http://www.example.com/sitemap.xml. Even better would be to automatically generate this file and updating the file on your live site.
The code required to accomplish the creation of the sitemap is very straightforward. Here is the code explained for each of the major sections:
This method uses the Media API to fetch all of the playlists for the account. If your account has more than 100 playlists, you will need to page through your playlists.
def fetch_playlists()
url = "http://api.brightcove.com/services/library?command=find_all_playlists
&get_item_count=true&token=#{MEDIA_API_TOKEN}"
resp = Net::HTTP.get_response(URI.parse(url))
data = resp.body
# we convert the returned JSON data to native Ruby
# data structure - a hash
result = JSON.parse(data)
# if the hash has 'Error' as a key, we raise an error
if result.has_key? 'Error'
raise "Error communicating with api.brightcove.com, exiting"
end
return result
end
After fetching each of the playlists, iterate over the contained videos and create a url element that can be added to the sitemap file:
def add_playlist_videos(playlist, sitemap)
playlist['videos'].each do | video |
# add the url element
url_element = Element.new("url", sitemap.root)
# add in location which is URL + playlist id and video id
loc_element = Element.new("loc", url_element)
loc_element.text = "#{LANDING_PAGE}?#{PLAYLIST_QUERY_PARAM_NAME}=#{playlist['id']}
&#{VIDEO_QUERY_PARAM_NAME}=#{video['id']}"
# add in lastmod element
lastmod_element = Element.new("lastmod", url_element)
# media api returns millis since epoch, convert to YYYY-MM-DD
# format as required by sitemap spec
lastmod_element.text = "#{Time.at(video['lastModifiedDate'].to_f/1000).strftime('%Y-%m-%d')}"
# add in change frequence
changefreq_element = Element.new("changefreq", url_element)
changefreq_element.text = "#{CHANGE_FREQUENCY}"
end
end
This is all that is needed to get your video pages to be indexed by the search engines via a sitemap file. Two things to note:
A video sitemap is similar in concept to the standard sitemap file; there will be an entry in this sitemap file per video in your account. In fact, a video sitemap uses the sitemap schema as its base and adds additional tags specific to video metadata.
We won't go through the meaning of every element in the video sitemap file, but we do want to touch upon two elements: <video:content_loc> and <video:player_loc>. According to the video sitemap specification:
You must provide one of either the <video:content_loc> or <video:player_loc>
The video:content_loc element would be used to provide a reference to the HTTP address for your UDS video file (FLV or MP4) directly.
For these reasons, we want to use the video:player_loc element rather than video:content_loc. This will point to a Single Video Player from the Video Cloud system via the Player URL publishing code. We can pass different video IDs to this player to play, using the bctid query parameter. We don't restrict this player to a particular domain and thus will allow it to be directly embedded in the search results.
The video:player_loc element can use a path like this:
http://c.brightcove.com/services/viewer/federated_f9/PLAYER_ID ?isVid=1&domain=embed&playerID=PLAYER_ID&videoID=VIDEO_ID&publisherID=PUBLISHER_ID
The only part of that path that will change from entry to entry is the videoID. The part of the path after federated_f9 is the id of a Video Cloud player that you have created. This should be a single video player. The path should include these values as query params:
Let's create a video sitemap for the content in your site. Here is an example of the video sitemap that will be created:
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
<url>
<loc>http://www.example.com/videos/some_video_landing_page.html</loc>
<video:video>
<video:content_loc>http://www.site.com/video123.flv</video:content_loc>
<video:player_loc allow_embed="yes">http://www.site.com/videoplayer.swf?video=123</video:player_loc>
<video:thumbnail_loc>http://www.example.com/thumbs/123.jpg</video:thumbnail_loc>
<video:title>Grilling steaks for summer</video:title>
<video:description>Get perfectly done steaks every time</video:description>
<video:publication_date>2007-11-05T19:20:30+08:00.</video:publication_date>
<video:tag>steak</video:tag>
<video:tag>meat</video:tag>
<video:tag>summer</video:tag>
<video:family_friendly>yes</video:family_friendly>
<video:duration>600</video:duration>
</video:video>
</url>
</urlset>
The code required to create a video sitemap is almost exactly the same as that to create a sitemap. The only difference is that we add additional metadata about each video into each url entry. Here is the modified add_playlist_videos method:
# Iterate over the videos in the playlist and add an entry
# to the sitemap for each video. This will include a unique URL
# to each video/playlist combination
def add_playlist_videos(playlist, sitemap)
playlist['videos'].each do | video |
# add the url element
url_element = Element.new("url", sitemap.root)
# add in location which is URL + playlist id and video id
loc_element = Element.new("loc", url_element)
loc_element.text = "#{LANDING_PAGE}?#{PLAYLIST_QUERY_PARAM_NAME}=#{playlist['id']}
&#{VIDEO_QUERY_PARAM_NAME}=#{video['id']}"
# add in the 'video' child element that contains video specific extensions
video_element = Element.new("video:video", url_element)
video_player_element = Element.new("video:player_loc", video_element)
video_player_element.add_attribute("allow_embed", "Yes")
video_player_element.text = "#{PLAYER_URL}?bctid=#{video['id']}"
video_thumb_element = Element.new("video:thumbnail_loc", video_element)
video_thumb_element.text = "#{video['thumbnailURL']}"
video_title_element = Element.new("video:title", video_element)
video_title_element.text = "#{video['name']}"
video_description_element = Element.new("video:description", video_element)
video_description_element.text = "#{video['shortDescription']}"
video_pub_element = Element.new("video:publication_date", video_element)
video_pub_element.text = "#{Time.at(video['lastModifiedDate'].to_f/1000).strftime('%Y-%m-%d')}"
video_duration_element = Element.new("video:duration", video_element)
video_duration_element.text = (video['length'].to_i/1000).to_s
video_family_element = Element.new("video:family_friendly", video_element)
video_family_element.text = "Yes"
# add in our tags
video['tags'].each do |tag|
video_tag_element = Element.new("video:tag", video_element)
video_tag_element.text = tag
end
end
end
Once you've created your video sitemap, you can submit it to Google following the instructions here.
You can use the source code attached to this article as is, or as a starting point. Several language flavors of the sitemap generators are supplied. This article uses Ruby in its code examples. You can download a zip file that includes:
generate_sitemap.rb – A Ruby script that can be used to create a standard sitemap file (not video-specific).generate_video_sitemap.rb – A Ruby script that can be used to create a video sitemap. It requires your site to a have a page that can take a playlist ID and video ID as parameters.generate_video_sitemap_for_player.rb – A script that can generate a video sitemap file for a multi-playlist player that is embedded on your site.There is also a PHP example with sample code you can download:
We also provide a zip file with sample code you can download that shows you how to generate a sitemap or video sitemap using Python:
A complete SEO strategy for your video content should include creating both a standard sitemap as well as a video sitemap. This will ensure that your content is indexed across the widest swath of search engines. Additionally, your content will be surfaced in the most aesthetically pleasing manner for the point of discovery. This article has outlined an approach for providing a unique URL per video in your account and sample code for generating the sitemap files that the engines will index.
Post new comment
Comments