2015-06-13 47 views
2

我想啓用Google Sitelinks搜索框爲網站。問題的關鍵是它的自定義搜索頁面由哈希代碼來實現這樣的JSON-LD數據片段是這樣的:啓用Google Sitelinks搜索框

<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> 

儘管谷歌試圖從這一部分"required name=search_term_string"提取信息以顯示站點鏈接搜索框,遇到問題:

: http://schema.org/True 
valueName: missing and required 

我懷疑也許谷歌只是希望搜索查詢字符串,而不是哈希代碼內串,你有什麼建議,除了重定向?

+1

可能重複測試工具](http://stackoverflow.com/questions/30780247/sitelinks-search-box-json-ld-giving-error-on-google-structured-data-testing-tool) – unor

回答

5

感謝@unor我找到了解決辦法,所以最後的代碼是這樣的:[鏈接搜索框JSON-LD在谷歌結構化數據給錯誤的

<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": { 
 
     \t \t "@type": "PropertyValueSpecification", 
 
     \t \t "valueRequired": true, 
 
     \t \t "valueMaxlength": 100, 
 
     \t \t "valueName": "search_term_string" 
 
    \t \t } 
 
      } 
 
     } 
 
</script>

+0

感謝您的解決方案 – waki

+2

@Waki和HosseinBakhtiari:請注意[這是Google的測試工具中的一個錯誤](http://stackoverflow.com/a/3114 5753/1591669),現已修復。所以原始標記似乎再次起作用。 – unor

+0

感謝@unor,順便說一句,谷歌需要花多少時間來響應這一變化,並在SERP內部顯示一個高流量網站(10,000個併發用戶)? –