微数据面包屑的 HTML5 验证

发布于 2025-01-05 19:51:05 字数 652 浏览 0 评论 0原文

我试图让我的页面进行验证,它现在抛出的唯一错误是:

此时元素 a 上不允许属性 itemprop 。

我的代码如下:

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

这遵循 Google 在以下页面上提供的电子邮件:

面包屑

这里似乎也遵循 HTML5 微数据规范:

HTML5 Microdata

有什么想法为什么这不能验证吗?我错过了什么,或者这对于验证者目前无法验证来说太新了?

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.

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:

Breadcrumbs

It also seems to follows the HTML5 Microdata specification as well here:

HTML5 Microdata

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

宛菡 2025-01-12 19:51:05

要让面包屑显示在 SERP 中,请像这样编码您的 schema.org 标记。请注意 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>

这在 Google 结构化数据测试工具中进行验证:

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

许多关于面包屑 schema.org 标记的文档都非常不正确。有一些关于此的线索。以上是我的工作解决方案,希望对您有所帮助。

To get breadcrumbs to show in SERPs, code your schema.org markup like this this. Notice the div nesting and the "child" property:

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

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

A lot of the documentation on schema.org markup for breadcrumbs is widely incorrect. There are a couple thread out there about this. Above is my working solution, hope it helps.

我的痛♀有谁懂 2025-01-12 19:51:05

您使用的是哪个验证器?有些尚不支持 HTML5 的最新功能,有些则支持,但由于您声明的文档类型而不会触发对文档的正确验证。

不过,新发布的Nu验证器应该不会出现这些问题。您可以在 .net 杂志上阅读相关内容。

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.

However, the newly released Nu validator shouldn't have these problems. You can read about it on .net magazine.

初相遇 2025-01-12 19:51:05

schema.org 已取代 data-vocabulary.org。 Schema.org 架构得到主要搜索引擎的认可。 Schema.org 的架构中没有 itemprop=url 。因此,可能是 Google 的工具或其搜索引擎机器人已停止遵循 data-vocabulary.org 模式。无论如何,最好转向 Schema.org 面包屑

项目类型 - 网页是网页的默认类型。因此,即使您不提供 itemtype - WebPage 并提供 BreadCrumb 类型,那么 Google 也会将其理解为面包屑。我在 Schema.org 页面上读到了这篇文章。我已经给了你这个链接。

使用此 Google 的工具进行验证。

schema.org has come in place of data-vocabulary.org. Schema.org schema is agreed upon by major search engines. And Schema.org does not have itemprop=url in its schema. So, may be Google's tool or its search engine robot has stopped following data-vocabulary.org schema. Anyway better shift to Schema.org Breadcrumb.

Itemtype - WebPage is default for a web page. So, even if you do not provide itemtype - WebPage and provide BreadCrumb type then Google will understand it as breadcrumb. I read this in Schema.org page. I have given you link for this.

Use this Google's tool for validation.

雪花飘飘的天空 2025-01-12 19:51:05
    <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>

这会将有关面包屑的许多数据暴露给爬虫。如果您将列表项设为内联,则输出将如下所示:

1.Home > 2.类别> 3.子类别

    <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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文