11

I use Google Chrome. When I want to search Wikipedia, I type www.wikipedia.org into the search bar and then press tab. The screen looks like this:

enter image description here

If I type some search words, it uses the actual search functionality of Wikipedia, instead of just returning a Google search of site:www.wikipedia.org x y z.

I have a site with search functionality using a regular html form, but I can't do the tab trick to search the site. Is there any way I can change my site's search page to be recognized by Chrome (and possibly other applications, if there's a standard format)? Google searching this only gives me results about registering my site with the Google search engine, frustratingly.

1 Answer 1

12

Ironically the answer is on this page and every other Stack Exchange site :)

You have to define an OpenSearchDescription for your site. If you look at the source code of this page you will see in the header:

<link rel="search" type="application/opensearchdescription+xml" title="Pro Webmasters - Stack Exchange" href="/opensearch.xml">

And if you open opensearch.xml referenced here you see:

<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">
<ShortName>Webmasters</ShortName>
<Description>Search Webmasters: Q&A for pro webmasters</Description>
<InputEncoding>UTF-8</InputEncoding>
<Image width="16" height="16" type="image/x-icon">http://sstatic.net/webmasters/img/favicon.ico</Image>
<Url type="text/html" method="get" template="http://webmasters.stackexchange.com/search?q={searchTerms}"/>
</OpenSearchDescription>

You have to implement the same for your site. The key is that you do need some kind of search implemented on you site which is used by the broswer to perform the actual search. This is specified in the template part of the XML:

http://webmasters.stackexchange.com/search?q={searchTerms}

Google Custom Search can be used for this purpose if you have no current search on your site.

6
  • Wikipedia.org doesn't seem to have that. Is Wikipedia just special or did I miss it?
    – Nate Glenn
    Commented Mar 4, 2013 at 21:54
  • @NateGlenn See en.wikipedia.org - Line 12 of the source-code :) Notice they use a PHP to generate the description.
    – Itai
    Commented Mar 4, 2013 at 21:57
  • I see now! What about metacpan.org? They have the OpenSearch thing, but Chrome doesn't recognize it and give me the tab shortcut, even after visiting it a bajillion times.
    – Nate Glenn
    Commented Mar 4, 2013 at 22:03
  • @NateGlenn Well. If Chrome does not recognize it, they may simply have a typo or error in it. I cannot diagnose it but I can tell you that the above procedure works for my own sites :)
    – Itai
    Commented Mar 4, 2013 at 22:05
  • Do you know what the xmlns:moz is there for, even though there are no moz namespace atts or tags anywhere?
    – Nate Glenn
    Commented Mar 4, 2013 at 22:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.