11

I would like to add microdata to a page, but the data for an item is broken up into a couple discontinuous parts of the page. If I have two span elements with an itemscope attribute, is it possible to get search engines to merge the two itemscopes and interpret them as a single item?

For example*:

<span itemscope itemtype="http://schema.org/Person">
    Hello, my name is <span itemprop="name">Glinda</span>.
</span>
I like to fly around in a giant bubble.
<span itemscope itemtype="http://schema.org/Person">
    I live in the <span itemprop="location">Land of Oz</span>.
</span>

Is there a way to add something like an itemid attribute to tell a web spider that the two Person itemscopes should be consumed as one item, instead of two?

Maybe something like this.

<span itemscope itemtype="http://schema.org/Person" itemid="7f6ba1">
    Hello, my name is <span itemprop="name">Glinda</span>.
</span>
I like to fly around in a giant bubble.
<span itemscope itemtype="http://schema.org/Person" itemid="7f6ba1">
    I live in the <span itemprop="location">Land of Oz</span>.
</span>

* I understand that in this example I could just use one big span, but I can't do that with the actual page I have to work with.

Edit: Perhaps I need a better example. It's a bit contrived, but demonstrates the problem I have. Remember, reorganizing the page is not an option.

<h1>Locations</h1>
  <ul>
    <li itemscope itemtype="http://schema.org/Person">
      <span itemprop="name">Bob</span> lives in <span itemprop="location">Berkeley</span>
    </li>
    <li itemscope itemtype="http://schema.org/Person">
      <span itemprop="name">Carol</span> lives in <span itemprop="location">Cupertino</span>
    </li>
  </ul>

<h1>Jobs</h1>
  <ul>
    <li itemscope itemtype="http://schema.org/Person">
      <span itemprop="name">Bob</span> works at <span itemprop="affiliation">Borders</span>
    </li>
    <li itemscope itemtype="http://schema.org/Person">
      <span itemprop="name">Carol</span> works at <span itemprop="affiliation">Capitol One</span>
    </li>
  <ul>

Is there a way to make this microdata result in two Person items, rather than four?

I want to have Bob, who lives in Berkeley, and works at Borders, and Carol who lives in Cupertino and works at Capitol One.

haydenmuhl
  • 5,998
  • 7
  • 27
  • 32

2 Answers2

12

If I'm reading the W3 itemref properly, you can use the itemref property for this purpose:

<h1>Locations</h1>
  <ul>
    <li  itemscope itemtype="http://schema.org/Person" itemref="bob">
      <span itemprop="name">Bob</span> lives in 
      <span itemprop="homeLocation">Berkeley</span>
    </li>
    <li  itemscope itemtype="http://schema.org/Person" itemref="carol">
      <span itemprop="name">Carol</span> lives in 
      <span itemprop="homeLocation">Cupertino</span>
    </li>
  </ul>
<h1>Jobs</h1>
  <ul>
    <li itemprop="affiliation" itemscope itemtype="http://schema.org/Organization" id="bob">
      Bob works at <span itemprop="name">Borders</span>
    </li>
    <li itemprop="affiliation" itemscope itemtype="http://schema.org/Organization" id="carol">
      Carol works at <span itemprop="name">Capitol One</span>
    </li>
  <ul>
stephanfriedrich
  • 563
  • 5
  • 20
Nate B
  • 6,338
  • 25
  • 23
  • I was looking through the spec, but missed this. This is the right answer, but your format is slightly wrong. The
  • elements in the Jobs list each need an itemscope and itemtype attribute. Fix that and I'll select this as the right answer.
  • – haydenmuhl Dec 03 '11 at 07:22
  • Edited, thanks. I wasn't sure from the examples in the documentation whether it needed the `itemscope` or not. – Nate B Dec 03 '11 at 16:38
  • @haydenmuhl: No, *Nate B*’s initial version was correct. Don’t use `itemscope` on the `itemref`'d elements, otherwise (as it’s currently the case) you still have 4 instead of 2 items. – unor Jan 28 '14 at 20:51
  • @NateB Doesn't the use of the `id` attribute only allow you to use that method once? Consider having 3 lists in your example, how would you add properties to `id="bob"` on the third list? – Fernando Silva Jun 30 '14 at 15:51