I am developing an application with Rails 3, one of requeriments is unique meta descriptions and keywords on each page to improve the SEO.
The client needs that this do automatically. How do you do this? Is better do this with Rails, Ruby or directly with Javascript?
Thanks.
Do it in Rails, not via javascript. Search Engines will not execute your javascript.
What I usually do is write a meta helper that I simply stick in my ApplicationHelper, that looks like this:
You can simply set meta tags in your views, by adding a call to meta() in it. So in an
articles/show.html.erbyou might add this to the top of your view:And in your layouts, you add it without any parameters, so it’ll spit out the meta tags.
Or have it output an individual tag:
I bet you there’s more elegant solutions, though. But if you were looking for something already implemented in Rails you’re out of luck.