62°F

Aaron Parecki

  • Articles
  • Notes
  • Photos
  • How to let Google power OpenSearch on your website

    July 11, 2011

    Firefox Search Bar

    OpenSearch is a collection of simple formats for the sharing of search results. One of the formats allows your browser to add your site to its list of search engines, which Firefox displays in the top right corner, and Chrome uses in the address bar. Adding a small link and XML document allows your site to be added to a browser.

    Many CMSs such as MediaWiki already support this natively so you might already have it on your site. To check in Chrome, in your search bar, enter your domain name followed by a space and see if it looks like the below screenshot.

    Chrome Search Bar

    If not, you’ll have to add a small link and XML file.

    The HTML code to reference the XML file is this:

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

    The XML file should look something like the following:

    <?xml version="1.0" encoding="UTF-8"?>
    <OpenSearchDescription xmlns:moz="http://www.mozilla.org/2006/browser/search/" 
          xmlns="http://a9.com/-/spec/opensearch/1.1/">
      <ShortName>aaron.pk</ShortName>
      <Description>Search aaron.pk</Description>
      <InputEncoding>UTF-8</InputEncoding>
      <Url method="get" type="text/html" 
          template="http://aaron.pk/search?q={searchTerms}"/>
    </OpenSearchDescription>
    

    But what if you want to add this to one of your sites that doesn't have search capability? Turns out there is no restriction on the domains that you can use for the search URL. This means we can delegate the search to google!

    Using Google's "site:example.com" feature, we can restrict the Google search to our domain.

    <?xml version="1.0" encoding="UTF-8"?>
    <OpenSearchDescription xmlns:moz="http://www.mozilla.org/2006/browser/search/" 
          xmlns="http://a9.com/-/spec/opensearch/1.1/">
      <ShortName>aaron.pk</ShortName>
      <Description>Search aaron.pk</Description>
      <InputEncoding>UTF-8</InputEncoding>
      <Url method="get" type="text/html" 
          template="http://www.google.com/search?q={searchTerms}+site%3Aaaron.pk&amp;hl=en"/>
    </OpenSearchDescription>
    

    Then, if someone uses your site's search, they get taken to a Google search results page with results from your site!

    Google site search

    Mon, Jul 11, 2011 1:53pm -07:00
    4 mentions

    Other Mentions

    • Malvoz github.com/Malvoz
      #6 Allow opensearch to use current browser search engine
      Sun, Jun 17, 2018 3:34pm -07:00
    • www.giantgeek.com
      Tue, Sep 9, 2014 10:50am -07:00
    • Aaron Parecki aaronparecki.com
      How to let Google power OpenSearch on your website
      Mon, Jul 11, 2011 1:53pm -07:00
    • search.yahoo.com
      Fri, Jul 5, 2019 4:08pm -07:00
Posted in /articles

Hi, I'm Aaron Parecki, Director of Identity Standards at Okta, and co-founder of IndieWebCamp. I maintain oauth.net, write and consult about OAuth, and participate in the OAuth Working Group at the IETF. I also help people learn about video production and livestreaming. (detailed bio)

I've been tracking my location since 2008 and I wrote 100 songs in 100 days. I've spoken at conferences around the world about owning your data, OAuth, quantified self, and explained why R is a vowel. Read more.

  • Director of Identity Standards at Okta
  • IndieWebCamp Founder
  • OAuth WG Editor
  • OpenID Board Member

  • 🎥 YouTube Tutorials and Reviews
  • 🏠 We're building a triplex!
  • ⭐️ Life Stack
  • ⚙️ Home Automation
  • All
  • Articles
  • Bookmarks
  • Notes
  • Photos
  • Replies
  • Reviews
  • Trips
  • Videos
  • Contact
© 1999-2025 by Aaron Parecki. Powered by p3k. This site supports Webmention.
Except where otherwise noted, text content on this site is licensed under a Creative Commons Attribution 3.0 License.
IndieWebCamp Microformats Webmention W3C HTML5 Creative Commons
WeChat ID
aaronpk_tv