173

When I enter some of URLs in Google Chrome omnibox, I see message in it "Press TAB to search in $URL". For example, there are some russian sites habrahabr.ru or yandex.ru. When you press TAB you'll be able to search in that site, not in your search engine. How to make my site to be able for it? Maybe, I need to write some special code in my site pages?

John Carter
  • 53,924
  • 26
  • 111
  • 144
Abzac
  • 2,631
  • 5
  • 21
  • 24

3 Answers3

220

Chrome usually handles this through user preferences. (via chrome://settings/searchEngines)

However, if you'd like to implement this specifically for your users, you need to add a OSD (Open Search Description) to your site.

Making usage of Google Chrome's OmniBox [TAB] Feature for/on personal website?

You then add this XML file to the root of your site, and link to it in your <head> tag:

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

Now, visitors to your page will automatically have your site's search information placed into Chrome's internal settings at chrome://settings/searchEngines.

OpenSearchDescription XML Format Example

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

The important part is the <url> item. {searchTerms} will be replaced with what the user searches for in the omnibar.

Here's a link to OpenSearch for more information.

Olivier Lalonde
  • 19,423
  • 28
  • 76
  • 91
element119
  • 7,475
  • 8
  • 51
  • 74
  • 10
    Note, that unlike Firefox, Chrome will discover your Open Search Description only if you put it on **the root of your website**. – varepsilon Dec 02 '14 at 09:08
  • 2
    is there a way to get that "omnibox-search" working with firefox? – JinSnow Mar 10 '15 at 07:21
  • How to find the url that leads directly to the query box on the target site? (in google translate for instance) – JinSnow Nov 07 '15 at 06:33
  • 2
    answer for google translate add this one to your search engine: http://translate.google.com/?source=osdd#auto|auto|%s – JinSnow Nov 11 '15 at 05:55
  • Adding search engines at `chrome://settings/searchEngines` is a time saver! Thanks! – Esdras Lopez Apr 02 '18 at 22:30
  • Chrome can also auto-detect search engine with a second heuristic. There are lots of restriction (GET only, no password, etc.). See the 2nd point here : https://www.chromium.org/tab-to-search/ (useful to know if you want to remove it from the omnibar) – BenC Mar 04 '22 at 08:44
  • 1
    It looks like Chrome no longer adds tab-to-search automatically: https://9to5google.com/2022/03/18/chrome-site-search-activate/ – Olivier Lalonde Jan 30 '23 at 23:01
37

Implementing omnibox support with search suggestions

The answer given by @element119 works perfect but here is a slightly tweaked code to support search suggestions as well as Mozilla Support.

Follow the steps below to implement omni box support for your site.

  1. Save the following code as 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. Upload search.xml to the root of your site.

  2. Add the following meta tag to your site's <head> tag

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

Make sure to replace the domain urls with your domain.

Shan Eapen Koshy
  • 2,909
  • 1
  • 28
  • 40
  • 1
    Is it `` or ``? I don't seems to find `SearchForm` in the OpenSearch docs and all other resources that I find online are using ``. – Niels R. Sep 22 '16 at 07:11
2

Google Chrome no longer supports the autodiscovery of site specific search

@googlechrome twitter account:
We made it so new Site search shortcuts are no longer automatically added to the Chrome search bar. We did this to help avoid cluttering it with Site search suggestions that people may not be using.

This response was originally provided in a comment (credit Olivier Lalonde) but I'm reposting it so it's easier to find (e.g. I didn't see this comment when I was originally looking for answers).

John
  • 9,249
  • 5
  • 44
  • 76