Schema.org Google 附加链接搜索框的 SearchAction 错误:"valueName: missing and required"

Schema.org SearchAction error for Google Sitelinks Search Box: "valueName: missing and required"

我们在网站上使用 Schema.org SearchAction,希望在 Google 搜索结果中显示附加链接搜索框。我已经完全按照 Google's Developer Page but it is still returning errors when I test it in Google's Test Tool.

上的说明实现了代码

这是我使用的代码:

<div itemscope itemtype="http://schema.org/WebSite">
    <meta itemprop="url" content="http://www.examplesite.com"/>
    <form itemprop="potentialAction" itemscope itemtype="http://schema.org/SearchAction">
        <meta itemprop="target" content="http://www.examplesite.com/catalogsearch/result/?q={q}"/>
        <input itemprop="query-input" type="text" name="q">
        <input type="submit">
    </form>
</div>

这是我遇到的错误:

如果可以的话,我想使用微数据,因为到目前为止我们所有的标记都使用它。有谁知道我该如何解决这个问题?

更新:在Google的测试工具中是a bug。问题中的标记(以及 Google 自己的文档)现在又可以使用了。所以不需要下面的替代方案。


不清楚这是否只是一个临时错误,因为他们的 Structured Data Testing Tool, or if their documentation for the Sitelinks Search Box 不再准确。

如果您认为他们的规则已更改(并且他们忘记更新文档),您可以通过提供 PropertyValueSpecification item and its valueName 属性(如错误消息所示)来修复它:

<div itemscope itemtype="http://schema.org/WebSite">
    <link itemprop="url" href="http://www.example.com"/> <!-- changed from 'meta' to 'link', as it’s required by HTML5 and Microdata -->
    <div itemprop="potentialAction" itemscope itemtype="http://schema.org/SearchAction">
        <meta itemprop="target" content="http://www.example.com/catalogsearch/result/?q={q}"/>
        <div itemprop="query-input" itemscope itemtype="http://schema.org/PropertyValueSpecification">
          <meta itemprop="valueName" content="q"/>
        </div>
    </div>
</div>

FWIW,这为结构化数据测试工具中的 "Sitelinks Search Box" 提供了 "all good"。