Plugins - seo_urls

StarAdd to favorites

seo_urls

Installation:

script/plugin install http://svn.redshiftmedia.com/svn/plugins/seo_urls

Usage:

To apply this plugin to a model:

class Post < ActiveRecord::Base

   seo_urls

end

Or to use an attribute other than name or title:

class Post < ActiveRecord::Base

   seo_urls "nickname"

end

Information

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 @post=>{:id=>12,:title=>"seo_urls rails plugin"}

Without the plugin: post_url(@post)=>"/posts/show/12"

With the plugin: post_url(@post)=>"/posts/show/12-seo-urls-rails-plugin"

If the value of the attribute being used to create the url string for a particular model changes, so will the resulting url string. However, old urls (which might have been stored in bookmarks etc.) will still work because rails only pays attention to the id reference number that begins the :id portion of any url, ignoring anything that follows it.

Resources

Subversion

Author

  • Tomasz Kaye. info [at] redshiftmedia [dot] com

Redshift Media

http://www.bitbutter.com/seo_urls-plugin-making-show-pages-more-findable/14

http://svn.redshiftmedia.com/svn/plugins/seo_urls

Rails' (MIT)

  • Currently 4.0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Model

Tags

Comments

Add a comment
chris 21 Apr 2008

FYI: This plugin can result in multiple URLs pointing to the same content such that there's no single permalink. This situation can be bad for SEO.

I suggest that your controller should check the url used for inbound access and send a 301 redirect if it's not the current one.

Also, SEO is better if you don't have an ID at the front of the URL, I recommend actsas_urlparam if you're looking for the best SEO possible.

chris 26 Jul 2007

Cool.

I rearranged the else statement to allow a function to be used as well to generate the name if the passed string isn't an attribute...

elsif self.respondto? attributeforurl.tosym string=self.send(attributeforurl)

Redshiftmedia 23 Jul 2007

At the time of writing the short install command isn't working, so please use:

script/plugin install http://svn.redshiftmedia.com/svn/plugins/seo_urls

Search Plugins

Query syntax

Plugins by Category

Sponsors

Rails Kits: Get Code. Get Moving.
Recruiting software

Have a comment?