Can I combine two itemscopes to describe a single item?
Asked Answered
L

2

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.

Launderette answered 2/12, 2011 at 20:7 Comment(0)
G
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>
Goal answered 2/12, 2011 at 23:57 Comment(4)
I was looking through the spec, but missed this. This is the right answer, but your format is slightly wrong. The <li> elements in the Jobs list each need an itemscope and itemtype attribute. Fix that and I'll select this as the right answer.Launderette
Edited, thanks. I wasn't sure from the examples in the documentation whether it needed the itemscope or not.Goal
@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.Sparrowgrass
@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?Kruller
G
0

Yes it is possible if you use the itemref property. Have a look at this website: IJzerfront 14-18

They link up the information (description and image are separated and are added to the Museum Place).

Gertrudegertrudis answered 16/3, 2016 at 15:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.