Metamagic is a simple Ruby on Rails plugin for creating meta tags.
In your Gemfile:
gem 'metamagic'
Then run bundle install
.
In your controller:
def show @product = Product.find(params[:id]) meta :title => @product.name, :description => @product.description, :keywords => @product.tag_list end
In your application.html.erb
:
<head> <title>My Site</title> ... <%= metamagic :title => "My default title", :description => "My default description.", :keywords => %w(keyword1 keyword2 keyword3) %> ... </head
For custom meta tags, just call it like this in your controller:
meta :title => "My title", :my_custom_tag => "My custom value"
To use in conjunction with the headliner plugin (github.com/mokolabs/headliner):
<%= metamagic :title => @title %>
Copyright © 2010 Lasse Bunk, released under the MIT license