Linking superEvent property in Microdata with itemref

心已入冬 提交于 2019-12-23 02:42:29

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!