使用schema.org WebPage和data-vocabulary.org Breadrumb

时间:2015-03-25 08:42:38

标签: html metadata breadcrumbs schema.org microdata

我希望通过添加schema.org WebPage词汇表中的元素(包括面包屑导航的语义标记)来语义上增强我的HTML标记。根据定义,我应该使用schema.org BreadcrumbList来实现这一目标。

但是在查看Google's documentation about adding structured data for Breadcrumbs时,他们明确声明尚未支持面包屑的schema.org标记。

Google statement about that they don't support breadcrumb markup with schema.org yet

相反,应该应用data-vocabulary.org Breadcrumb的明显较旧的定义。这似乎是因为schema.org BreadcrumbList is still disputed。实际上Google在他们的Structured Data Testing Tool中解析schema.org BreadcrumbList标记,但是不要在搜索结果中使用它来表示良好的表示,就像使用data-vocabulary.org Breadcrumb定义注释的面包屑一样。

但是,将两个世界结合在一起并对网页和面包屑进行语义标记会很不错。最好的我能想出这样的结果(使用itemref来防止需要将每个Breadcrumb嵌套到另一个中):

<body itemscope itemtype="http://schema.org/WebPage">
  <h1 itemprop="name">George Orwell</h1>
  <p itemprop="description">Eric Arthur Blair (25 June 1903 – 21 January
  1950), who used the pen name George Orwell, was an English novelist,
  essayist, journalist and critic.</p>

  <nav itemprop="breadcrumb">
    <ul itemscope>
      <li id="bc1"itemscope itemref="bc2"
        itemtype="http://data-vocabulary.org/Breadcrumb">
        <a href="http://example.com/books" itemprop="url">
          <span itemprop="title">Books</span>
        </a> ›
      </li>
      <li id="bc2" itemscope itemprop="child" itemref="bc3"
        itemtype="http://data-vocabulary.org/Breadcrumb">>
        <a href="http://example.com/books/authors" itemprop="url">
          <span itemprop="title">Authors</span>
        </a> ›
      </li>
      <li id="bc3" itemscope itemprop="child"
        itemtype="http://data-vocabulary.org/Breadcrumb">>
        <a href="http://example.com/books/authors/orwell" itemprop="url">
          <span itemprop="title">George Orwell</span>
        </a>
      </li>
    </ul>
  </nav>

</body>

itemscope上的<ul>属性是必需的,因此后面带有itemprop="child"的面包屑不会被解释为WebPage的属性。

当我在结构化数据测试工具中抛出此代码时,所有数据都会被识别为我想要的,但是对于未定义的ul项有警告。

忽略这些错误是否安全?是否有其他方法甚至是最佳实践来解决问题?对于面向未来的问题:在多年来可能无法更新的网站上使用此类代码是否明智?

1 个答案:

答案 0 :(得分:1)

在测试您的标记时,Google’s Testing Tool似乎没有报告任何错误或警告。它为每件物品说“一切都好”。

您对Microdata的使用是有效的。您正在添加没有类型的项目,该项目没有任何内容(因为没有添加任何属性)。

使用Schema.org的breadcrumb property似乎是合适的,因为它的预期类型之一是 Text 。因此,Schema.org消费者只会提取子项的文本内容,而不是URL:

  

图书>&gt;作者>&gt;乔治奥威尔


我不认为linked issue是Google不支持Schema.org BreadcrumbList的原因:问题是从2012年开始,但BreadcrumbList类型是{{3}仅几个月前(2014-12-11)到Schema.org 问题是关于使用没有类型的breadcrumb属性(当时不存在),这是不理想的,因为这不允许为每个面包屑指定元数据(例如,其URL)。


面向未来的方法是将两个词汇表用于面包屑。 Microdata语法使这个added,但RDFa语法允许这样做(但是,Data-Vocabulary.org的奇怪要求是必须嵌套面包屑可能需要更改标记)。

相关问题