简体   繁体   English

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

[英]Is it okay to have the same itemprop and itemscope itemtype on multiple location on the page

Is it okay to set the same itemprop and itemscope on the document or is it bad practice? 可以在文档上设置相同的itemprop和itemscope,还是不好的做法?

The reason I ask is my view layout doesn't display the type in a linear fashion, eg. 我问的原因是我的视图布局没有以线性方式显示类型,例如。 a company avatar is be on the sidebar and the company name which is the title is on the article > header block. 公司头像位于侧边栏上,公司名称是标题,位于article > header标题栏上。

Code example: 代码示例:

<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>

I declared the itemprop="seller" and itemscope itemtype="http://schema.org/Organization" twice because of how I need to style the page. 我两次声明了itemprop="seller"itemscope itemtype="http://schema.org/Organization" ,因为我需要为页面设置样式。

  1. Displaying the company name 显示公司名称
  2. Displaying the company url 显示公司网址

This is not ideal. 这不太理想。 It conveys that the order has two sellers. 它传达了订单有两个卖家。 Consumers could guess/assume that it's the same seller, but they can't know for sure. 消费者可以猜测/假设它是同一个卖家,但他们无法确定。

itemid

Microdata's itemid attribute allows you to give an item a URI (this URI identifies the entity described by this item; it doesn't necessarily have to lead to a page, but it's a good practice to provide a page with information about the item). Microdata的itemid属性允许您为项目提供URI(此URI 标识此项目描述的实体;它不一定必须指向页面,但提供包含项目信息的页面是一种很好的做法)。 By giving both of your Organization items the same URI, you convey that these items are about the same entity. 通过为两个Organization项目提供相同的URI,您可以传达这些项目是同一个实体。

When doing this, there doesn't seem to be any need to provide the seller property a second time. 这样做时,似乎没有必要再次提供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>

(Note: You could also use an external URI for itemd , eg, http://acme-supplies.com/ , assuming that this URI identifies the seller, and not something else in addition. Strictly speaking, this URI could also represent the seller's website, etc. Ideally the seller would itself provide a URI that identifies it, but not many do.) (注意:您也可以使用itemd的外部URI,例如http://acme-supplies.com/ ,假设此URI标识卖家,而不是其他内容。严格来说,此URI也可以代表卖方的网站等。理想情况下,卖方本身会提供一个标识它的URI,但并不是很多。)

itemref

Another solution, if it's possible for you to move the second Organization element out of the Order element, is Microdata's itemref attribute. 另一种解决方案是,如果你可以将第二个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>

The Organization element adds (via its itemref attribute) the property defined in the element with the ID seller-acme-supplies-url . Organization元素添加(通过其itemref属性)元素中使用ID itemref seller-acme-supplies-url定义的属性。

You have to make sure that the element with the id is not a child of another itemscope (otherwise it would also become the url of that item). 您必须确保具有id的元素不是另一个itemscope的子元素(否则它也将成为该项目的url )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM