启用 Google 附加链接搜索框
Enabling Google Sitelinks Search Box
我想为网站启用 Google 附加链接搜索框。关键是它的自定义搜索页面是通过散列片段实现的,所以JSON-LD数据片段是这样的:
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "WebSite",
"name" : "my site",
"alternateName" : "example.com",
"url": "http://www.example.com/",
"potentialAction": {
"@type": "SearchAction",
"target": "http://www.example.com/Search/#!/Keyword-{search_term_string}",
"query-input": "required name=search_term_string"
}
}
</script>
虽然Google试图从这部分提取信息"required name=search_term_string"
以显示附加链接搜索框,但遇到问题:
: http://schema.org/True
valueName: missing and required
我怀疑 Google 可能只是希望在 查询字符串 中搜索字符串而不是 散列片段 ,你有什么建议除了重定向?
感谢@unor,我找到了解决方案,所以最终代码是这样的:
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "WebSite",
"name" : "example",
"alternateName" : "example.com",
"url": "http://www.example.com/",
"potentialAction": {
"@type": "SearchAction",
"target": "http://www.example.com/Search/#!/Keyword-{search_term_string}/",
"query-input": {
"@type": "PropertyValueSpecification",
"valueRequired": true,
"valueMaxlength": 100,
"valueName": "search_term_string"
}
}
}
</script>
我想为网站启用 Google 附加链接搜索框。关键是它的自定义搜索页面是通过散列片段实现的,所以JSON-LD数据片段是这样的:
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "WebSite",
"name" : "my site",
"alternateName" : "example.com",
"url": "http://www.example.com/",
"potentialAction": {
"@type": "SearchAction",
"target": "http://www.example.com/Search/#!/Keyword-{search_term_string}",
"query-input": "required name=search_term_string"
}
}
</script>
虽然Google试图从这部分提取信息"required name=search_term_string"
以显示附加链接搜索框,但遇到问题:
: http://schema.org/True
valueName: missing and required
我怀疑 Google 可能只是希望在 查询字符串 中搜索字符串而不是 散列片段 ,你有什么建议除了重定向?
感谢@unor,我找到了解决方案,所以最终代码是这样的:
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "WebSite",
"name" : "example",
"alternateName" : "example.com",
"url": "http://www.example.com/",
"potentialAction": {
"@type": "SearchAction",
"target": "http://www.example.com/Search/#!/Keyword-{search_term_string}/",
"query-input": {
"@type": "PropertyValueSpecification",
"valueRequired": true,
"valueMaxlength": 100,
"valueName": "search_term_string"
}
}
}
</script>