简体   繁体   English

正确使用Microdata中的ListItem?

[英]Proper use of ListItem in Microdata?

I am passing the SDTT, and the information even looks orderly in the SDTT result. 我通过了SDTT,信息甚至在SDTT结果中看起来井井有条。 But I suspect this is going to fail when I go online because I can't find this approach anywhere else. 但是我怀疑这在我上网时会失败,因为在其他任何地方都找不到这种方法。

Do I need to include itemprop="itemListElement" in each div , and repeat for each item, or have I developed a shortcut that will actually work? 我是否需要在每个div包括itemprop="itemListElement"并为每个项目重复,或者我是否开发了一种可以实际使用的快捷方式?

<div itemscope itemtype="http://schema.org/ListItem">
    <p itemprop="name">My list</p>
    <p itemprop="description">blurb about the list</p>

   <meta itemprop="position" content="1"/>
        <p itemprop="name">first item name</p>
        <p itemprop="description">blurb about the first item</p>

    <meta itemprop="position" content="2">
    <!-- repeat as above... -->

</div>

Please give some guidance regarding the correctness of this approach. 请提供有关此方法正确性的一些指导。

You have to provide the itemListElement property (with item values). 您必须提供itemListElement属性(带有项目值)。

In your snippet, you are adding all properties to a single ListItem (I assume you meant to use ItemList , but it doesn't change the problem). 在您的代码段中,您正在将所有属性添加到单个ListItem (我假设您打算使用ItemList ,但不会改变问题)。 This means that this item has multiple names ( name ), multiple descriptions ( description ), and multiple positions ( position ). 这意味着该项目具有多个名称( name ),多个描述( description )和多个位置( position )。

Microdata doesn't capture the order of the HTML elements. 微数据不会捕获HTML元素的顺序。 So the following HTML snippets produce equivalent Microdata: 因此,以下HTML代码段会生成等效的微数据:

<div itemscope>
  <meta itemprop="position" content="1" />
  <meta itemprop="position" content="2" />
</div>
<div itemscope>
  <meta itemprop="position" content="2" />
  <meta itemprop="position" content="1" />
</div>

(Schema.org defined the position property exactly because Microdata doesn't care about the order in the HTML, so the order has to be specified explicitly if it's relevant.) (Schema.org正是由于Microdata不在乎HTML中的顺序而定义了position属性,因此如果相关,则必须明确指定顺序。)

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

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