3

I’m trying to set a song’s duration with Microdata. What is the best way to describe a duration in Microdata?

Is it by using itemprop="duration" in span?

<span itemprop="duration" content="PT4M5S">4:05</span>

Or using the time element?

<time itemprop="duration" datetime="PT4M5S">4:05</time>

Or using the meta element?

<meta itemprop="duration" content="PT4M5S"/>4:05

Or a combination of all of them?

<span itemprop="duration" content="PT4M5S">
    <time itemprop="duration" datetime="PT4M5S">
        <meta itemprop="duration" content="PT4M5S"/>4:05
    </time>
</span>

I tried and they all worked in Google’s Structured Data Testing Tool, except for the last one where the result were three durations!

2 Answers 2

3

Complete details along with examples can be viewed on MusicRecording Schema.

Specifically, the below is the correct markup for this type of data:-

<div itemscope itemtype="http://schema.org/MusicGroup">

<h1 itemprop="name">Foo Fighters</h1>


<div itemprop="video" itemscope itemtype="http://schema.org/VideoObject">
  <h2>Video: <span itemprop="name">Interview with the Foo Fighters</span></h2>
  <meta itemprop="duration" content="T1M33S" />
  <meta itemprop="thumbnail" content="foo-fighters-interview-thumb.jpg" />
  <object ...>
    <param ...>
    <embed type="application/x-shockwave-flash" ...>
  </object>
  <span itemprop="description">Catch this exclusive interview with
    Dave Grohl and the Food Fighters about their new album, Rope.</span>
</div>


<h2>Songs</h2>

<div itemprop="track" itemscope itemtype="http://schema.org/MusicRecording">
  <span itemprop="name">Rope</span>
  <meta itemprop="url" content ="foo-fighters-rope.html">
  Length: <meta itemprop="duration" content="PT4M5S">4:05 -
  14300 plays<meta itemprop="interactionCount" content="UserPlays:14300" />
  <a href="foo-fighters-rope-play.html" itemprop="audio">Play</a>
  <a href="foo-fighters-rope-buy.html" itemprop="offers">Buy</a>
  From album: <a href="foo-fighters-wasting-light.html"
    itemprop="inAlbum">Wasting Light</a>
</div>

<div itemprop="track" itemscope itemtype="http://schema.org/MusicRecording">
  <span itemprop="name">Everlong</span>
  <meta itemprop="url" content ="foo-fighters-everlong.html">
  Length: <meta itemprop="duration" content="PT6M33S">6:33 -
  <span itemprop="playCount">11700</span> plays
  <a href="foo-fighters-everlong-play.html" itemprop="audio">Play</a>
  <a href="foo-fighters-everlong-buy.html" itemprop="offers">Buy</a>
  From album: <a href="foo-fighters-color-and-shape.html"
    itemprop="inAlbum">The Color And The Shape</a>
</div>


<h2>Upcoming shows</h2>

<div itemprop="event" itemscope itemtype="http://schema.org/Event">
  <a href="foo-fighters-may20-fedexforum" itemprop="url">
    <span itemprop="name">FedExForum</span>
  </a>
  <span itemprop="location">Memphis, TN, US</span>
  <meta itemprop="startDate" content="2011-05-20">May 20
  <a href="ticketmaster.com/foofighters/may20-2011" itemprop="offers">Buy tickets</a>
</div>

<div itemprop="event" itemscope itemtype="http://schema.org/Event">
  <a href="foo-fighters-may23-midamericacenter" itemprop="url">
    <span itemprop="name">Mid America Center</span>
  </a>
  <span itemprop="location">Council Bluffs, IA, US</span>
  <meta itemprop="startDate" content="2011-05-23">May 23
  <a href="ticketmaster.com/foofighters/may23-2011" itemprop="offers">Buy tickets</a>
</div>

<h2><a href="foo-fighters-photos">28 Photos</a></h2>
<a href="foofighters-1.jpg" itemprop="image"><img src="foofighters-thumb1.jpg" /></a>
<a href="foofighters-2.jpg" itemprop="image"><img src="foofighters-thumb2.jpg" /></a>
<a href="foofighters-3.jpg" itemprop="image"><img src="foofighters-thumb3.jpg" /></a>


<h2>Comments:</h2>
Excited about seeing them in concert next week. -Lawrence , Jan 23
I dig their latest single. -Mary, Jan 19
<meta itemprop="interactionCount" content="UserComments:18" />
Showing 1-2 of 18 comments. <a href="foofighters-comments">More</a>

</div>
1

The duration property expects a Duration as value, which has to be in the ISO 8601 duration format.

The time element can have a "valid duration string" as value (which is based on one of the ISO 8601 formats). Your value "PT4M5S" would be valid.

So you should use

<time itemprop="duration" datetime="PT4M5S">4:05</time>

Microdata parsers have to use the value of the datetime attribute, if present.

(You should use the meta element only if you can’t markup visible content.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.