All threads / How do I add opensearch to a Rails app
Ask A Question


You’re not receiving notifications from this thread.

How do I add opensearch to a Rails app

Dan Frenette asked in General

I'm talking about the feature in chrome, it's present on GoRails, where if you type the URL of the site and hit Tab, you're able to search the site from the Chrome omnibar. I've gotten this to work with Firefox, and with just adding my site's search engine into Chrome, but for some reason I can't get the tab functionality to work.

Here's my XML file:

<OpenSearchDescription xmlns=""
  <ShortName>My Website</ShortName>
  <Description>Something Short Here</Description>
  <Url type="text/html" method="get" template="<%= request.base_url %>/searches?q={searchTerms}"/>

and the link tag in my header:

%link{:href => open_searches_path, rel: "search", title: "Rails Garden", type: "application/opensearchdescription+xml"}/

That's a great question. I've never intentionally added that feature to GoRails, so I don't actually know. :-) In fact, I don't think there's any OpenSearch tags or anything so I wonder if they can detect a standard like /search url or something in my case.

I think I'd have to describe that answer as delightfully frustrating :) I'm happy Chrome threw you a bone and just tacked it on. Maybe I just need to push my site up and see what happens. Either way, thanks so much for the response!

Hahaha yeah! :P

I got a chance to read this article:

It looks like your XML file and stuff should match up with what he manually wrote out. I think you should try pushing to production and load up the XML url and make sure it renders properly with the right urls and everything and see if Google picks it up over the next few days. Pretty sure you've got it setup right.

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 70,078+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

    © 2023 GoRails, LLC. All rights reserved.