富媒体搜索结果测试检测到存在错误 "missing field 'id'"

Rich results test detects error "missing field 'id'" while it is present

关注 this guide from Google。我正在将微数据添加到我网站的面包屑中。

在测试我自己的代码时,我收到“id”字段丢失的错误,而这不是我能看到和理解的。我是不是遗漏了一些东西,还是 Google 的测试工具中的错误?

您可以在 https://search.google.com/test/rich-results/result 使用以下代码进行自我测试。

    <html>
      <head>
        <title>Microdata test</title>
      </head>
        <body>
            <div class="container">
                <div class="row">
                    <div class="col-12 col-lg-10 offset-lg-1">
                        <nav aria-label="breadcrumb" class="breadcrumb top">
                            <ol class="breadcrumb" itemscope itemtype="https://schema.org/BreadcrumbList">
                                <li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem" class="breadcrumb-item">
                                    <a itemid="http://localhost/hikes-and-walks" href="http://localhost/hikes-and-walks" itemprop="item" itemscope itemtype="https://schema.org/WebPage"><span itemprop="name">Home</span></a>                        <meta itemprop="position" content="1" />
                                </li>
                                <li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem" class="breadcrumb-item">
                                    <a itemid="http://localhost/hikes-and-walks/hikes/bulgaria" href="http://localhost/hikes-and-walks/hikes/bulgaria" itemprop="item" itemscope itemtype="https://schema.org/WebPage"><span itemprop="name">Bulgaria</span></a>                        <meta itemprop="position" content="2" />
                                </li>
                                <li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem" class="breadcrumb-item active" aria-current="page">
                                    <span itemprop="name">Aleko hut to Zheleznitsa village</span>
                                    <meta itemprop="position" content="3" />
                                </li>
                            </ol>
                        </nav>
                    </div>
                </div>
            </div>
        </body>
    </html>

它给出错误“缺少字段 'id'”:

这可能是由于一些难以掌握的内部验证。看起来 itemid 需要特定的 URL 结构。在这种情况下,相对或绝对 URL (protocol+root+tld) 工作,i.e.changing "http://localhost""http://localhost.site" 通过测试。相对 URL 也有效。

因此,将 itemid URL 更改为:

绝对URL:

itemid="http://localhost.site/hikes-and-walks"

或亲戚URL:

itemid="/hikes-and-walks"

此外,这些(有效的)示例将不起作用:

urn:isbn:9780307476463

file:///ada/Analytical%20Engine/README.md   

ftp://file

这是工作代码:

<html>
  <head>
    <title>Microdata test</title>
  </head>
    <body>
        <div class="container">
            <div class="row">
                <div class="col-12 col-lg-10 offset-lg-1">
                    <nav aria-label="breadcrumb" class="breadcrumb top">
                        <ol class="breadcrumb" itemscope itemtype="https://schema.org/BreadcrumbList">
                            <li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem" class="breadcrumb-item">
                                <a itemid="http://localhost.site/hikes-and-walks" href="http://localhost/hikes-and-walks" itemprop="item" itemscope itemtype="https://schema.org/WebPage"><span itemprop="name">Home</span></a>                        <meta itemprop="position" content="1" />
                            </li>
                            <li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem" class="breadcrumb-item">
                                <a itemid="http://localhost.site/hikes-and-walks/hikes/bulgaria" href="http://localhost/hikes-and-walks/hikes/bulgaria" itemprop="item" itemscope itemtype="https://schema.org/WebPage"><span itemprop="name">Bulgaria</span></a>                        <meta itemprop="position" content="2" />
                            </li>
                            <li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem" class="breadcrumb-item active" aria-current="page">
                                <span itemprop="name">Aleko hut to Zheleznitsa village</span>
                                <meta itemprop="position" content="3" />
                            </li>
                        </ol>
                    </nav>
                </div>
            </div>
        </div>
    </body>
</html>