我们必须做什么才能让 Google 的多功能栏显示针对我们域的自定义搜索:
就像如果我们进入多功能栏并输入 s-t-a-c-k-o-v-e-r-f-l-o-w-.-c-o-m-[SPACE] ,栏就会出现,例如在框中输入 asd 将直接进入 https://stackoverflow.com/search? q=asd
我注意到这种行为与维基百科的行为不同(维基百科将我们带到http://en.wikipedia.org/w/index.php?title=Special:Search&search=asd)
YouTube 的行为也不同(这将我们带到 http://www.youtube.com/results?search_query=asd&page=&utm_source=opensearch)
当然不是所有域都有这种行为,请尝试:g-o-d-a-d-d-y-.-c-o-m-[SPACE] 什么都不做
我如何指示谷歌的多功能栏搜索我的域名的方式?
就是每页
<head>
中的这一行:
<link rel="search" type="application/opensearchdescription+xml" title="Stack Overflow" href="/opensearch.xml">
以及它指向的文件:
<?xml version="1.0" encoding="UTF-8" ?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"
xmlns:moz="http://www.mozilla.org/2006/browser/search/">
<ShortName>Stack Overflow</ShortName>
<Description>Search Stack Overflow: Q&A for professional and enthusiast programmers</Description>
<InputEncoding>UTF-8</InputEncoding>
<Image width="16" height="16" type="image/x-icon">http://sstatic.net/stackoverflow/img/favicon.ico</Image>
<Url type="text/html" method="get" template="http://stackoverflow.com/search?q={searchTerms}"></Url>
</OpenSearchDescription>
它称为 OpenSearch,是指定如何搜索网站的标准方法。请参阅 GitHub 上的 OpenSearch 描述规范、MDN 文档中的 OpenSearch 描述格式参考以及 Wikipedia 上的 OpenSearch 背景。