正确的面包屑微数据标记

Coo*_*oop 12 html seo microdata schema.org

在研究如何为网页面包屑做微数据时,我发现了几种方法,我不确定哪种方法是正确的.首先,我在HTML中的基本面包屑看起来像这样:

<div>
  <a href="/">Root page</a>
  <a href="/category">Category page</a>
  <a href="/category/this-page">This page</a>
</div>
Run Code Online (Sandbox Code Playgroud)

现在,我是否像这样构建它(正如我在SchemaOrg示例中看到的那样:

<ol itemscope itemtype="http://schema.org/BreadcrumbList">
  <li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
    <a href="/" itemprop="item">
      <span itemprop="name">Root page</span>
    </a>
  </li>
  <li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
    <a href="/category" itemprop="item">
      <span itemprop="name">Category page</span>
    </a>
  </li>
  <li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
    <a href="/category/this-page" itemprop="item">
      <span itemprop="name">This page</span>
    </a>
  </li>
</ol>
Run Code Online (Sandbox Code Playgroud)

或者像我在Stackoverflow的一些答案中看到的那样构造它如下所示:

<div>
  <span itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
    <a href="/" itemprop="url">
      <span itemprop="title">Root page</span>
    </a>
  </span>
  <span itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
    <a href="/category" itemprop="url">
      <span itemprop="title">Category page</span>
    </a>
  </span>
  <span itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
    <a href="/category/this-page" itemprop="url">
      <span itemprop="title">This page</span>
    </a>
  </span>
</div>
Run Code Online (Sandbox Code Playgroud)

还是我不知道的另一种方法?

Fla*_*orm 5

现代(2019)正确的面包屑微数据标记如下所示。

而且,如果您要投诉最佳做法,请不要将最后一个面包屑项目作为页面上的链接-您可以使用,<span>而不用<a>这种方式:

<ol itemscope itemtype="http://schema.org/BreadcrumbList">
  <li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
    <a itemscope itemtype="http://schema.org/Thing" itemprop="item" href="/" itemid="/">
      <span itemprop="name">Root page</span>
    </a>
    <meta itemprop="position" content="1" />
  </li>
  <li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
    <a itemscope itemtype="http://schema.org/Thing" itemprop="item" href="/category" itemid="/category">
      <span itemprop="name">Category page</span>
    </a>
    <meta itemprop="position" content="2" />
  </li>
  <li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
    <span itemscope itemtype="http://schema.org/Thing" itemprop="item" itemid="/category/this-page">
      <span itemprop="name">This page</span>
    </span>
    <meta itemprop="position" content="3" />
  </li>
</ol>
Run Code Online (Sandbox Code Playgroud)

此代码完全符合要求BreadcrumbList(另请参阅该项目的ID),并通过https://search.google.com/structured-data/testing-tool上的Google验证通过。