How to create SEO friendly URL’s on your rails web application

When you are creating something for the web, you have to keep in mind that your website must be as easy to find as possible. You need to think of the best companies who can help build links for you so that you can internally generate more provide with leading people to another website. Keep in mind there are SEO agency/ agencies that are willing to help your web grow, like for example SEO Boise.

What is the average SEO Adelaide prices? The average SEO price in Australia ranges from $750 to $3,000+ per month. See the full price range and calculate your Seo packages for small businesses to get an estimate.

SEO, or Search Engine Optimization ( should always be in your mind when designing and creating your website. A great company, like Edmonton Alberta SEO that work’s for local Edmonton businesses, can create a web design to fit your communication goals, brand guidelines and target audience and tracking your customers journey map should be a big part of that (

Lets imagine a blog. By default the route to each post would be something like:
which works just fine.
But this is not SEO friendly, as the search engine crawlers won’t link the URL to the content.

A more friendly URL would include the post title, so the crawler links it directly to the content. Although this raises a problem: what about special chars?

Well, this little workaround does the trick. The idea is for a post with a title like “This is the post title :)” to create a url like this “this-is-the-post-title”.
Downcasing and replacing all the non letters and non numeric characters.

Let’s see how:

1 – Create a field called url on your class/table

2 – Create a helper class called SeoHelper in a file called seo_helper.rb, with the following content

class SeoHelper

  def self.to_url (sentence)
     sentence.downcase.gsub(/[^a-z0-9]+/i, '-')

3 – Before saving your object, populate the url with method provided by the helper class

def Save
    post =[:post])
    post.url = SeoHelper.to_url(post.title)

4 – On the blog page, look for the url field instead of the post id.


2 thoughts on “How to create SEO friendly URL’s on your rails web application”

  1. Hello there! Do you know if they make any plugins to assist with
    Search Engine Optimization? I’m trying to get my blog to rank for some targeted keywords but I’m not seeing
    very good gains. If you know of any please
    share. Cheers!

Leave a Reply

Your email address will not be published. Required fields are marked *



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>