架构标记:如何暂时"逃避"的itemscope

时间:2015-10-05 15:56:37

标签: html5 schema.org microdata

我想使用Schema标记一些内容,但我的itemcopes遇到了问题。

我现在有以下标记:

<div itemscope itemtype="https://schema.org/medicalClinic">
  <div itemprop="availableService" itemscope itemtype="https://schema.org/MedicalProcedure">
    <span itemprop="name">First Service Name</span>
    <span itemprop="description">First Service Description</span>
    <div itemprop="availableService itemscope itemtype="https://schema.org/MedicalProcedure">
      <span itemprop="name">Second Service Name</span>
      <span itemprop="description">Second Service Description</span>
    </div><!-- end second service -->
    <span itemprop="followup">First Service Followup</span>
  </div><!-- end first service -->
</div><!-- end MedicalClinic schema -->

由于内容的结构方式,第二项服务出现在第一项服务的容器中间。第一次服务的Itemprops出现在第二次服务之前和之后。

Google's structured data testing tool显示错误,指出availableService不是availableService的属性(显然不是我想要的)。

我的问题是我如何&#34;逃避&#34;我的第一个服务的范围所以我能够标记我的第二个服务,然后重新进入第一个服务的范围?

1 个答案:

答案 0 :(得分:2)

有一个丑陋的解决方案,包括添加div itemscope(不itemtype)和itemref + id

<div itemscope itemtype="http://schema.org/MedicalClinic" itemref="second-service">

  <div itemprop="availableService" itemscope itemtype="http://schema.org/MedicalProcedure">
    <span itemprop="name">First Service Name</span>
    <span itemprop="description">First Service Description</span>

    <div itemscope>

      <div itemprop="availableService" itemscope itemtype="http://schema.org/MedicalProcedure" id="second-service">
        <span itemprop="name">Second Service Name</span>
        <span itemprop="description">Second Service Description</span>
      </div><!-- end second service -->

    </div> <!-- end dummy div -->

    <span itemprop="followup">First Service Followup</span>
  </div><!-- end first service -->

</div><!-- end MedicalClinic schema -->

关于您的标记的说明:

  • 您可能需要use HTTP instead of HTTPS Schema.org URIs
  • Schema.org URI区分大小写(例如,http://schema.org/MedicalClinic,而不是http://schema.org/medicalClinic
  • 您错过了itemprop关闭"
相关问题