사이트에 Google 크롬 검색 주소창 검색 지원을 추가하는 방법은 무엇입니까? habrahabr.ru 또는 yandex.ru가

Chrome 검색 주소창에 일부 URL을 입력하면 ‘$ URL에서 검색하려면 Tab 키를 누르세요’라는 메시지가 표시됩니다. 예를 들어 일부 러시아 사이트 habrahabr.ru 또는 yandex.ru가 있습니다. Tab 키를 누르면 검색 엔진이 아닌 해당 사이트에서 검색 할 수 있습니다. 내 사이트를 활성화하려면 어떻게해야합니까? 내 사이트 페이지에 특수 코드를 작성해야합니까?



답변

Chrome은 일반적으로 사용자 기본 설정을 통해이를 처리합니다. (통하다chrome://settings/searchEngines )

그러나 사용자를 위해이 기능을 구현하려면 사이트에 OSD (Open Search Description)를 추가해야합니다.

개인 웹 사이트에 Chrome의 OmniBox [TAB] 기능을 사용하십니까?

그런 다음이 XML 파일을 사이트의 루트에 추가하고 <head>태그 에서 링크하십시오 .

<link rel="search" type="application/opensearchdescription+xml" title="Stack Overflow" href="/opensearch.xml" />

이제 페이지 방문자는 사이트의 검색 정보를 자동으로 Chrome의 내부 설정에 배치합니다. chrome://settings/searchEngines 합니다.

OpenSearchDescription XML 형식 예

<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">
<ShortName>Your website name (shorter = better)</ShortName>
<Description>
Description about your website search here
</Description>
<InputEncoding>UTF-8</InputEncoding>
<Image width="16" height="16" type="image/x-icon">your site favicon</Image>
<Url type="text/html" method="get" template="http://www.yoursite.com/search/?query={searchTerms}"/>
</OpenSearchDescription>

중요한 부분은 <url>항목입니다. {searchTerms}검색 주소창에서 사용자가 검색 한 내용으로 바뀝니다.

자세한 내용 은 OpenSearch에 대한 링크 입니다.


답변

추천 검색어로 검색 주소창 지원 구현

@ element119의 답변은 완벽하게 작동하지만 Mozilla 지원뿐만 아니라 검색 제안을 지원하기 위해 약간 조정 된 코드가 있습니다.

아래 단계에 따라 사이트에 옴니 박스 지원을 구현하십시오.

  1. 다음 코드를 search.xml 로 저장하십시오.
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">
  <script/>
  <ShortName>Site Name</ShortName>
  <Description>Site Description (eg: Search sitename)</Description>
  <InputEncoding>UTF-8</InputEncoding>
  <Image width="16" height="16" type="image/x-icon">Favicon url</Image>
  <Url type="application/x-suggestions+json" method="GET" template="http://suggestqueries.google.com/complete/search?output=firefox&amp;q={searchTerms}" />
  <Url type="text/html" method="GET" template="http://yoursite.com/?s={searchTerms}" />
  <SearchForm>http://yoursite.com/</SearchForm>
</OpenSearchDescription>
  1. search.xml 을 사이트의 루트에 업로드 하십시오.

  2. 사이트의 <head>태그에 다음 메타 태그 추가

<link rel="search" href="http://www.yoursite.com/search.xml" type="application/opensearchdescription+xml" title="You site name"/>

도메인 URL을 도메인으로 바꾸십시오.