Permalinks, Slugs and Friendly URLs with Ruby on Rails

One thing almost every customer hates to see is http://domain/resource/id.  They will complain that they look bad.  They will cite that they can’t remember the URL because of some number that doesn’t mean anything.  They get nervous that investors or others will know they only have a certain number of records.  They will get nervous that people will just try random numbers and get data that doesn’t make sense.  Savvy clients even will complain that it will hurt their ability to rank well on search engines for their content.

There are lots of ways to work around this, but there are a lot of little gotchas.  Data can change and your URL’s can break and disrupt your SEO.  If there is lots of similar content there is difficulty in making sure URLs stay unique.  As an application grows it can become a pain to maintain friendly URLs.  Don’t forget possible name spacing issues.

A plugin by Norman on Github called FriendlyId solves all the problems at once.  If you need to do Friendly URLs, permalinks or want slugs check out this plug-in.

Some nice  features

  • Slugged/Non-Slugged Models
  • Slug Versioning
  • Unique Slug Names
  • Reserved Names
  • Slug Caching
  • Scoped Slugging
  • Text Normalization
  • Diacritic-sensitive Normalization
  • Unicode URLs
  • Custom Slug Generation

Step up to the mic.

Your email address will not be published.