是否可以在页面上的多个位置上使用相同的itemprop和itemscope项类型

时间:2016-08-01 10:26:05

标签: html schema.org microdata

可以在文档上设置相同的itemprop和itemscope,还是不好的做法?

我问的原因是我的视图布局没有以线性方式显示类型,例如。公司头像位于侧边栏上,公司名称是标题,位于article > header区块。

代码示例:

<div itemscope itemtype="http://schema.org/Order">
  <div itemprop="seller" itemscope itemtype="http://schema.org/Organization">
    <b itemprop="name">ACME Supplies</b>
  </div>

  <div class="reviews">
     <p>Great company! - Jane</p>
  </div>

  <div itemprop="seller" itemscope itemtype="http://schema.org/Organization">
    <span itemprop="url">http://acme-supplies.com</span>
  </div>
</div>

我宣布itemprop="seller"itemscope itemtype="http://schema.org/Organization"两次,因为我需要为页面设置样式。

  1. 显示公司名称
  2. 显示公司网址

1 个答案:

答案 0 :(得分:2)

这不太理想。它传达了订单有两个卖家。消费者可以猜测/假设它是同一个卖家,但他们无法确定。

itemid

Microdata的itemid属性允许您为项目提供URI(此URI 标识此项目描述的实体;它不一定必须指向页面,但它是提供包含项目信息的页面的好习惯。通过为两个Organization项提供相同的URI,您可以传达这些项是关于同一个实体的。

执行此操作时,似乎无需再次提供seller属性。

<div itemscope itemtype="http://schema.org/Order">
  <div itemprop="seller" itemscope itemtype="http://schema.org/Organization" itemid="/seller/acme-supplies#this">
    <b itemprop="name">ACME Supplies</b>
  </div>

  <div class="reviews">
     <p>Great company! - Jane</p>
  </div>

  <div itemscope itemtype="http://schema.org/Organization" itemid="/seller/acme-supplies#this">
    <a itemprop="url" href="http://acme-supplies.com/">acme-supplies.com</a>
  </div>
</div>

(注意:您也可以使用itemd的外部URI,例如http://acme-supplies.com/,假设此URI标识卖家,而不是其他内容。严格来说,此URI也可以代表卖家的网站等。理想情况下,卖家本身会提供一个识别它的URI,但不是很多。)

itemref

另一种解决方案,如果您可以将第二个Organization元素移出Order元素,则是Microdata的itemref属性。

<div itemscope itemtype="http://schema.org/Order">
  <div itemprop="seller" itemscope itemtype="http://schema.org/Organization" itemref="seller-acme-supplies-url">
    <b itemprop="name">ACME Supplies</b>
  </div>

  <div class="reviews">
     <p>Great company! - Jane</p>
  </div>
</div>

<div>
    <a itemprop="url" href="http://acme-supplies.com/" id="seller-acme-supplies-url">acme-supplies.com</a>
</div>

Organization元素(通过其itemref属性)添加了ID为seller-acme-supplies-url的元素中定义的属性。

您必须确保id的元素不是另一个itemscope的子元素(否则它也将成为该项目的url。)

相关问题