How to Generate SEO Friendly URL in Rails 3.x

Rails3
Social sharing

Rails3SEO friendly URLs are more important to make a page popular & search engines to crawl.

FriendlyId is the slugging and permalink plug-in for Ruby on Rails. It allows you to create pretty URLs and work with human-friendly strings.

The URLs created by slug are very useful for SEO. It is designed for generation of URL slug and history maintenance.

Contents

Steps to create Pretty URLs:

Step#1

Include gem in your Gem file:

gem 'friendly_id'

Then run bundle install.

Step#2

Modify your model on which you want the pretty URL:

extend FriendlyId
 
friendly_id :title, use: :slugged

Step#3

Add the slug column in your migration file to add it on the table

add_column :articles, :slug, :string

Then run

rake db:migrate

Now if you create an article with Title like “This is a demo title for testing”,
it will create a SEO friendly URL like “this-is-a-demo-title-for-testing” and will
save into the articles table under slug column.

Your recently viewed posts:

Jayadev Das - Post Author

Do what you do best in – that’s what I’ve always believed in and that’s what I preach. Over the past 25+ years (yup that’s my expertise ‘n’ experience in the Information Technology domain), I’ve been consulting to small, medium and large companies ‘About Web Technologies, Mobile Future as well as on the good-and-bad of tech. Blogger, International Business Advisor, Web Technology Expert, Sales Guru, Startup Mentor, Insurance Sales Portal Expert & a Tennis Player. And top of all – a complete family man!

    Contact Us

    We’d love to help & work with you




    When do you want to start ?


    Enter your email address to stay up to date with the latest news.
    Holler Box

    Orange Exit pop up

    Subscribe for the latest
    trends in web and
    mobile app development
    Holler Box

    Exit pop up

    Sad to see you leaving early...

    From "Aha" to "Oh shit" we are sharing everything on our journey.
    Enter your email address to stay up to date with the latest news.
    Holler Box