简体   繁体   English

微型数据面包屑的HTML5验证

[英]HTML5 validation for Microdata Breadcrumbs

I'm trying to get my pages to validate and the only error it is now throwing is: 我正在尝试验证我的页面,现在抛出的唯一错误是:

Attribute itemprop not allowed on element a at this point. 目前,元素a上不允许使用itemprop属性。

My code is as follows: 我的代码如下:

<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
  <a href="http://www.example.com/dresses" itemprop="url">
    <span itemprop="title">Dresses</span>
  </a>
</div>  

This follows the email given by Google on the following page: 这是Google在以下页面上发送的电子邮件:

Breadcrumbs 面包屑

It also seems to follows the HTML5 Microdata specification as well here: 这里似乎也遵循HTML5微数据规范:

HTML5 Microdata HTML5微数据

Any ideas why this doesn't validate? 有什么想法为什么不能验证? What am I missing or is this just too new to for the validator to validate at the moment? 我缺少什么,或者对于验证者而言,这太新了以至于无法验证?

To get breadcrumbs to show in SERPs, code your schema.org markup like this this. 要使面包屑显示在SERP中,请像这样编写您的schema.org标记。 Notice the div nesting and the "child" property: 请注意div嵌套和“ child”属性:

<div class="breadcrumb" itemscope itemtype="http://data-vocabulary.org/Breadcrumb">

  <span class="breadcrumb-lead">YOU ARE HERE:</span>
  <a title="Go to %title%." href="%link%" class="%type%" itemprop="url">
  <span itemprop="title">Homepage</span></a>

  <div itemprop="child" itemscope itemtype="http://data-vocabulary.org/Breadcrumb" style="display: inline;">
    <a title="Go to %title%." href="%link%" class="%type%" itemprop="url">
    <span itemprop="title">Category One</span></a>
  </div>

  <div itemprop="child" itemscope itemtype="http://data-vocabulary.org/Breadcrumb" style="display: inline;">
    <a title="Go to %title%." href="%link%" class="%type%" itemprop="url">
    <span itemprop="title">Category Two</span></a>
  </div>

</div>

This validates in Google Structured Data Testing Tool: 这可以在Google结构化数据测试工具中进行验证:

http://www.google.com/webmasters/tools/richsnippets http://www.google.com/webmasters/tools/richsnippets

A lot of the documentation on schema.org markup for breadcrumbs is widely incorrect. 有关面包屑的schema.org标记的很多文档都是错误的。 There are a couple thread out there about this. 有一些关于这个的话题。 Above is my working solution, hope it helps. 以上是我的工作解决方案,希望对您有所帮助。

schema.org has come in place of data-vocabulary.org. schema.org已经取代了data-vocabulary.org。 Schema.org schema is agreed upon by major search engines. Schema.org模式已得到主要搜索引擎的同意。 And Schema.org does not have itemprop=url in its schema. 并且Schema.org在其架构中没有itemprop = url。 So, may be Google's tool or its search engine robot has stopped following data-vocabulary.org schema. 因此,可能是Google的工具或其搜索引擎机器人已停止遵循data-vocabulary.org模式。 Anyway better shift to Schema.org Breadcrumb . 无论如何,最好转移到Schema.org Breadcrumb

Itemtype - WebPage is default for a web page. Itemtype-WebPage是网页的默认设置。 So, even if you do not provide itemtype - WebPage and provide BreadCrumb type then Google will understand it as breadcrumb. 因此,即使您不提供itemtype-WebPage并提供BreadCrumb类型,Google也会将其理解为Breadcrumb。 I read this in Schema.org page. 我在Schema.org页面中阅读了此内容。 I have given you link for this. 我已经给你链接了。

Use this Google's tool for validation. 使用此Google 工具进行验证。

    <ol itemscope itemtype="http://schema.org/BreadcrumbList">
  <li itemprop="itemListElement" itemscope
      itemtype="http://schema.org/ListItem">
    <a itemprop="item" href="https://www.example.com">
        <span itemprop="name">Home</span></a>
    <meta itemprop="position" content="1" />
  </li>
  ›
  <li itemprop="itemListElement" itemscope
      itemtype="http://schema.org/ListItem">
    <a itemprop="item" href="https://www.example.com/category1">
      <span itemprop="name">Category 1</span></a>
    <meta itemprop="position" content="2" />
  </li>
  ›
  <li itemprop="itemListElement" itemscope
      itemtype="http://schema.org/ListItem">
    <a itemprop="item" href="https://www.example.com/category1/subcategory">
      <span itemprop="name">SubCategory</span></a>
    <meta itemprop="position" content="3" />
  </li>
</ol>

This will expose many data regarding the breadcrumb to the crawler. 这会将与面包屑有关的许多数据公开给搜寻器。 If you make the list items inline, the output will be as follows: 如果使列表项内联,则输出将如下所示:

1.Home > 2.Category > 3.SubCategory 1.主页> 2.类别> 3.子类别

Which validator were you using? 您使用的是哪个验证者? Some don't support the newest features of HTML5 yet, and some do but won't trigger proper validation for your document because of the doctype that you declare. 有些不支持HTML5的最新功能,有些则支持,但是由于声明的文档类型而不会触发对文档的正确验证。

However, the newly released Nu validator shouldn't have these problems. 但是,新发布的Nu验证程序应该不会出现这些问题。 You can read about it on .net magazine . 您可以在.net杂志上阅读有关内容。

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

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