Topic: Dynamically Generate Meta Tags

Hi,
I have a site that I am working on and it uses partials. The main part of the site includes the head information (title, meta name description, meta name keywords etc...)and then in the body the rest of the site is pulled in using partials.
For each page I do not want to use the same title, keywords and description and was wondering what the best way was to create these for each page that uses the partial.
Thanks,

Re: Dynamically Generate Meta Tags

Forget about the keywords and description and just change the title based on whatever the page is about. (Instance variable)

http://danielfischer.com - Personal Web-Technology-Blog, Los Angeles.

Re: Dynamically Generate Meta Tags

I will change the title but keywords and description are still important to some of the search engines. Google may place less relevance on them now but some of the smaller search engines still use them, the big three (Google, Yahoo and Live) do use the page descriptions as well in their rankings.
I am not trying to turn this into a discussion on SEO but instead am looking on for the best way to proceed in generating keywords and description.

Re: Dynamically Generate Meta Tags

You can use content_for to do this:

# in partial/template
<% content_for :head do %>
  <meta ...>
<% end %>

# in layout
<head>
  ...
  <%= yield :head %>
</head>


There's also a railscast that shows you how to do this.

Is that what you were looking for?

Railscasts - Free Ruby on Rails Screencasts

Re: Dynamically Generate Meta Tags

Thanks Ryan,
That sounds like what I need, I will definitely check out RailsCast #8 as soon as possible. I think I am on #6 currently so I am a few behind. Thanks for the excellent Rails site and all the work you have put into helping the community.