Google likes titles to be distinct for every page and they use that for page rank. My old layout had the same title for every page. I looked up dynamic layout in this group and followed the suggestion for page specific titles. Now I have a ''@title'' variable in the controllers, I assign it in index and other routines like this: ''def index @title = "something" end'' whatever is the appropriate title for that page and then in the layout I have ''<title> <%= @title => </title>'' This WORKS in the test environment but when I capistrano upload the app to the production environment title is ALWAYS blank, an empty string. Any suggestions? thanks, minka http://www.beelucid.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
minka wrote:> Google likes titles to be distinct for every page and they use that > for page rank. My old layout had the same title for every page. I > looked up > dynamic layout in this group and followed the suggestion for > page specific titles. Now I have a > ''@title'' > variable in the controllers, I assign it in index and other routines > like this: > ''def index > @title = "something" > end'' > whatever is the appropriate title for that page and then in the layout > I have > ''<title> <%= @title => </title>'' > > This WORKS in the test environment but when I capistrano upload the > app to the production environment title is ALWAYS blank, an empty > string. >Ah, there is a much more elegant way of doing this! :-) ActionView has a content_for method, which you can use. Here is a blog post explaining how it works (with some extra stuff) http://blog.imperialdune.com/2007/3/27/dirty-views-clean-them-up In a nutshell... in your application layout. <title>DHH Gossip » <%= (title = yield :title) ? title : ''Your source for the latest DHH gossip'' %></title> Then in your views... # news.rhtml <% content_for :title do %>DHH kills Bat Boy!<% end %> When rendered, this will appear in your. As you can see, I also defined a default string above. You can do several content_for''s in your app (sidebar, navigation, breadcrumbs...) Good luck! Cheers, Robby -- Robby Russell http://www.robbyonrails.com/ http://www.planetargon.com/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Robby Russell wrote:> minka wrote: >> Google likes titles to be distinct for every page and they use that >> for page rank. My old layout had the same title for every page. I >> looked up >> dynamic layout in this group and followed the suggestion for >> page specific titles. Now I have a >> ''@title'' >> variable in the controllers, I assign it in index and other routines >> like this: >> ''def index >> @title = "something" >> end'' >> whatever is the appropriate title for that page and then in the layout >> I have >> ''<title> <%= @title => </title>'' >> >> This WORKS in the test environment but when I capistrano upload the >> app to the production environment title is ALWAYS blank, an empty >> string. >> > > Ah, there is a much more elegant way of doing this! :-) > > ActionView has a content_for method, which you can use. > > Here is a blog post explaining how it works (with some extra stuff) > > http://blog.imperialdune.com/2007/3/27/dirty-views-clean-them-up > > In a nutshell... in your application layout. > > > <title>DHH Gossip » <%= (title = yield :title) ? title : ''Your > source for the latest DHH gossip'' %></title> > > > Then in your views... > > # news.rhtml > > <% content_for :title do %>DHH kills Bat Boy!<% end %> > > When rendered, this will appear in your. As you can see, I also defined > a default string above. > > You can do several content_for''s in your app (sidebar, navigation, > breadcrumbs...)Also, here is the documentation for content_for. http://api.rubyonrails.com/classes/ActionView/Helpers/CaptureHelper.html#M000638 Cheers, Robby -- Robby Russell http://www.robbyonrails.com/ http://www.planetargon.com/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---