Ruby on Rails and Canonical link tag

On February Google, Yahoo, and Microsoft announced support for a new link element to clean up duplicate URLs on sites. The element is called Canonical Link tag and the syntax is pretty simple.

This tag, added in the HEAD section of an HTML page, tells search engines that the preferred location for the content of the request page is the value of the href attribute, in this case http://example.com/page. If you want to learn more about the canonical link tag, have a look at Matt Cutt’s introductory post or Google Webmaster Central.

The new version of my Helperful Rails plugin provides a new method named canonical_link_tag, a super simple helper to generate the canonical link tag. The usage is similar to the auto_complete_link_tag helper.

```ruby canonical_link_tag # => <link rel=”canonical” href=http://www.currenthost.com/controller/action” />

canonical_link_tag(:action => “show”) # => <link rel=”canonical” href=http://www.currenthost.com/controller/show” />

canonical_link_tag(“http://www.example.com/product.php?item=swedish-fish”) # => ```

You can install or upgrade Helperful via RubyGems.

$ gem install weppos-helperful --source http://gems.github.com