【问题标题】:Multiple occurences of same itemprop in Microdata schema.orgMicrodata schema.org 中多次出现相同的 itemprop
【发布时间】:2014-03-11 15:39:29
【问题描述】:

我在 google 上测试了我的微数据 schema.org:

google 工具没有返回任何错误...

**Item** 
    type:   http://schema.org/webpage
    property:   
    url:    http://127.0.0.1/
    image:  http://127.0.0.1/design/logo.jpg
    datemodified:   2014-03-05 20:12:56
    text:   
    Item 1
    breadcrumb: Skip to content
    text:   
    Item 2



    **Item 1**
    type:   http://schema.org/wpheader
    property:   
    url:    http://127.0.0.1
    headline:   website name
    image:  http://127.0.0.1/design/logo.jpg
    description:    some text


    **Item 2**
    type:   http://schema.org/sitenavigationelement

你可以看到我在网页类型中使用了多个...

有效吗?

如果是,您知道 WebPage 类型的 itemprop="url" 无效...或者 ItemList 的 itemListElement 有效。如何识别哪个 itemprop 有效,哪个无效?

----------------///编辑///--------------------------------

<html itemscope itemtype="http://schema.org/webpage">
<body>
<div itemprop="text" itemscope="itemscope" itemtype="http://schema.org/wpheader">
...
</div>

<div itemprop="text" itemscope="itemscope" itemtype="http://schema.org/SiteNavigationElement">
...
</div>
</body>
</html>

【问题讨论】:

  • 如果您没有收到错误,为什么还要质疑它的有效性?
  • 因为对一种网页类型使用 double itemprop="url" 无效但谷歌实验室不返回任何错误!
  • 我不确定我是否完全理解您的要求。你的问题是是否允许在同一个项目中多次拥有相同的属性?
  • 谢谢亲爱的 unor...我读到了'schema.org/WebPage'...I 谢谢它是真的...就像你对我的回答之一关于 itemList
  • @user3307827:我还是不明白你的问题。你能试着改写一下吗?

标签: html microdata schema.org


【解决方案1】:

您可以为同一项目多次拥有相同的属性(例如,specify Schema.org’s name in different languages)。但请注意Microdata doesn’t define what it should mean 指定同一属性不止一次时。

所以这样的事情完全没问题:

<html itemscope itemtype="http://schema.org/WebPage">
  <body>
    <div itemprop="text">…</div>
    <div itemprop="text">…</div>
  </body>
</html>

(请注意,您的具体示例可能存在问题:Schema.org 的 text property 需要 Text,但您正在使用另一个项目作为值。不过,这不是被禁止的。)

(还要注意大小写很重要,所以它必须是http://schema.org/WPHeader 而不是http://schema.org/wpheader。与http://schema.org/WebPage 相同。)

【讨论】:

  • 所以根据您的回答如果我将您示例中的
    标签更改为
    schema.org/SiteNavigationElement">,it 是正确的!对吗?
  • @user3307827:这很难回答。这是正确的微数据,是的。但是 Schema.org 希望您在此处使用由文本组成的值,而不是(如您的示例中)由另一种类型(SiteNavigationElement)组成的值。但这可能不是错误(请参阅"Expected types" on schema.org)。毕竟这是一个 expected(而不是 required)类型。所以是的,你可能会这样使用它。
猜你喜欢
相关资源
最近更新 更多
热门标签