schema.org - 启用 Google 附加链接搜索框

标签 schema.org google-rich-snippets json-ld

我想为网站启用 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>

关于schema.org - 启用 Google 附加链接搜索框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30815872/

相关文章:

soundcloud - 使用 itemprop 音频标记 iframe 音频播放器是否合适?

schema.org - 通过 JSON-LD schema.org 连接多个组织和网站

html - 网站名称结构化标记数据

seo - google rich snippets(评论)显示完全不正确?

html - 如何处理 CreativeWork 文本属性内的标记

navigation - 如何使用 JSON-LD 创建 SiteNavigationElement?

java - Sesame/Jena SPARQL 结果转为 JSON-LD

seo - 您能否在 schema.org 微数据值中使用 utf-8 或 HTML 实体转义(十六进制)代码?

schema.org - Schema.org 中的产品列表

seo - 在工作人员中使用 Rich Snippet Person 的正确性如何?