Easy Google Sitemap with REST in Rails
February 21st, 2007
Google Sitemaps are an effective way to let Google know which pages of your website are available for indexing. Though they go to great lengths to point out that submitting a sitemap is only a suggestion, and not a command, Google does use your sitemap to provide insights into how your website is being indexed and found by web searchers.
Here’s how I added a Google Sitemap for Moral Metric in two shakes of a lamb’s tail.
First, I made sure that my HomeController
was defined as a resource in my routes.rb
file:
|
map.resource :home
|
My HomeController
is very sparse – it only has one public method: index
. I wanted to have my application return XML when Google asked for XML, so rather than adding a new method, I used Rails’ respond_to blocks: