我們在我們的網站上使用Schema.org SearchAction
,希望在Google搜索結果中顯示附加鏈接搜索框。我已經完全按照它在Google's Developer Page上所說的那樣來執行代碼,但是當我在Google's Test Tool中進行測試時,它仍然返回錯誤。Schema.org SearchAction error for Google Sitelinks搜索框:「valueName:missing and required」
這裏是我使用的代碼:
<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>
這是我得到的錯誤:
我想,如果我可以使用微因爲到目前爲止我們所有的標記都使用它。有誰知道我怎麼能解決這個問題?
目標中的{q}和valueName中的q是否需要與用戶輸入的實際搜索值匹配?這是我從文檔中完全不瞭解的。所以我只是靜態設置它以匹配我們的搜索結果頁面用於搜索的字母。 – njm5785
花括號'{'和'}'裏面的字符串只是一個佔位符,你選擇哪一個並不重要(它只需要匹配'valueName'的值)。在您的示例中,搜索的查詢參數與佔位符相同,但不一定是。例如,你可以使用這個'target' URI:'http://www.example.com/catalogsearch/result/?q= {foobar}',然後你必須使用這個'valueName'值: 'foobar'。是的,它是靜態的(它只是告訴搜索引擎必須替換哪些字符串,以便爲您的網站生成有效的搜索網址)。 – unor
@Nick:我更新了我的答案:您的原始標記現在再次生效。 – unor