seo_urls plugin: Making 'show' pages more findable
Google favours pages when important keywords are reflected in their urls. Normally a page in a rails application that shows a single record has a url that looks like this recipes/show/12. If this particular recipe is for pasta sauce, Google would prefer the url to be recipes/show/12-pasta-sauce. Because rails isn't interested in what appears after the number in the :id part of the url, we are free to add words there to help search engines without affecting how our application functions.
The seo_urls plugin aims to make it easy to create more descriptive urls for 'show' pages and increase your application's visibility to search engines.
Install from the root of your application like so:
script/plugin install http://svn.redshiftmedia.com/svn/plugins/seo_urls
Apply the plugin to a model like this:
# Apply it to a model like this:
end
# Or to use an attribute other than name or title:
end
The plugin looks for 'name' or 'title' attributes and if they are available it uses them to generate a search engine friendly string. to_param method is overwritten so that it returns the the numerical id of the record with the search engine friendly string appended to it.
# An example model
@recipe=>{:id=>12,:title=>"pasta sauce"}
# Without the plugin:
recipe_url(@recipe)=>"/recipes/show/12"
# With the plugin:
recipe_url(@recipe)=>"/recipes/show/12-pasta-sauce"
Trackbacks
Use this link to trackback from your own site.

Nice Plugin. But your example is unclear. You set the titel to "seo_urls rails plugin". So the post_url(@post) should return "/recipes/show/12-seo_urls_rails_plugin".
Thanks for pointing that out David, I've fixed the example.
This is brilliant!
There are a number of solutions that allow you to do permalinks and SEO urls, but I stumbled accross one issue and that was integration with the methds ActiveResource creates for a model (like posts_url).
This plugin completely solves that issue! And it doesn't use tables like the urlnamable plugin which means you have to have a 'urlnames' table which seems kinda unnecessary…
Nice one Bitbutter.
[…] http://www.bitbutter.com/seo_urls-plugin-making-show-pages-more-findable/14 […]