问题
I'm adding Microdata to a page and I'm trying to associate a list of events to a superEvent, but I don't manage to make it work when checking at: http://www.google.com/webmasters/tools/richsnippets?q=
Here the concept code:
<div id="main" itemscope="main" itemtype="http://schema.org/Event">
<span itemprop="name">Main
</div>
<div itemscope="event" itemtype="http://schema.org/Event">
<span itemprop="name">Event
<span itemprop="superEvent" itemref="main">
</div>
Any idea?
回答1:
Problems with your Microdata:
itemscope
is a boolean attribute, so you should not give it values like "main" or "event".The
itemref
attribute can only be used on elements with itemscope, so you can’t use it like that.
To link events via the subEvent/superEvent properties, you could either use the itemref
attribute or nest the items.
With itemref
and superEvent, it could look like:
<div itemprop="superEvent" itemscope itemtype="http://schema.org/Event" id="main">
<span itemprop="name">Main</span>
</div>
<div itemscope itemtype="http://schema.org/Event" itemref="main">
<span itemprop="name">Event</span>
</div>
With itemref
and subEvent, it could look like:
<div itemscope itemtype="http://schema.org/Event" itemref="secondary">
<span itemprop="name">Main</span>
</div>
<div itemprop="subEvent" itemscope itemtype="http://schema.org/Event" id="secondary">
<span itemprop="name">Event</span>
</div>
Nesting (without using itemref
) could look like:
<div itemscope itemtype="http://schema.org/Event">
<span itemprop="name">Main</span>
<div itemprop="subEvent" itemscope itemtype="http://schema.org/Event">
<span itemprop="name">Event</span>
</div>
</div>
回答2:
I managed to do this in the end:
<div id="main" itemprop="superEvent" itemscope="main" itemtype="http://schema.org/Event">
<span itemprop="name">Main
</div>
<div itemscope="event" itemtype="http://schema.org/Event" itemref="main">
<span itemprop="name">Event
</div>
来源:https://stackoverflow.com/questions/26651213/linking-superevent-property-in-microdata-with-itemref