Did you ever see in Google Chrome or Chromium the term “Press Tab to search” behind a site URL when typing in an URL? This is very handy to search this site with Google, but is it possible to make this in your own site? The answer is Yes, and it is easy to do this. This article is made for Wordpress sites, but you can do the same with an another CMS only the PHP files are different.

Creating the Open Search Description document

First create in the root of your website the file opensearchdescription.xml (same directory as your wp-config.php file). This can be done by FTP or your ISP manager tool. The opensearchdescription.xml file contains:

<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<ShortName>Your Website Name</ShortName>
<Description>Use Google to search Your Website Name</Description>
<Url type="text/html" template="http://www.google.com/search?q=site:www.example.com {searchTerms}"/>

Replace the bold string Your Website Name with the name of your website. Replace the bold string www.example.com with the domainname of your website.

Google Chrome will look in the head of page to the following linktype to enable the “Tab to Search” function.

<link type="application/opensearchdescription+xml" rel="search" href="http://www.example.com/opensearchdescription.xml"/>

Replace the bold string www.example.com with the domainname of your website.

To add this link type into Wordpress perform the following actions:

  • Login to your Wordpress admin page
  • Go to menu: Appearance->Editor
  • Click on Header to open the header.php file
  • Search for “<?php wp_head(); ?>”
  • Copy the given linktype row just above the <?php wp_head(); ?> function

In my case this part of the header.php file looks like this:

<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link type="application/opensearchdescription+xml" rel="search" href="/opensearchdescription.xml"/>
<?php wp_head(); ?>

Background information

Chromium.org/tab-to-search Opensearch.org/Specifications/OpenSearch/1.1