Posts Tagged ‘ruby’

simple search engine optimization steps

January 23, 2009 , Written By  Surendra Singhi.

Here are few simple and easy steps which you can take to ensure your website is search engine friendly.

  1. Make sure that your page urls are descriptive. For example look at the post urls of this page. They are of the form http://blog.kreeti.com/seo/simple-search-engine-optimization-steps. This is very easy to do in rails. Add the following code to the models:
    1. def to_param
    2.     "#{id}-#{name.gsub(/[^a-z0-9]+/i, ‘-’)}"
    3. end

    and then while linking to posts, use code like

    1. user_path(@user)

    and not

    1. user_path(@user.id) # do not use this
  2. Ensure that your pages have a meaningful page title, meta description and meta keywords. Title and description should be preferably unique for each page, and relevant to the page. One simple strategy which you can follow to do this in rails is, in the layout file add the following code:
    1. <title><%= @page_title || "Default page title" %></title>

    and similarly for meta description and keywords.

    Then in your actions you can override the default values

    1. @page_title = "New title"
    2. @page_description = "new description"
    3. @meta_keywords = "keyword1,keyword2,.."
  3. Make sure that all links to meaningless and duplicate pages have rel=”nofollow”. For example, pagination links, links which just sort the page content in a different order, etc., all should have rel=”nofollow” for them. This will ensure that the search engines, when propagating the authority of your page to other linked pages, doesn’t waste them on useless pages, or duplicate links.
  4. When multiple items on a page are linking to the same page, make sure that all the links with irrelevant terms have rel=”nofollow”, only the links with terms which aptly describe the page shouldn’t have rel=”nofollow”.
  5. Duplicate versions of your page, say with a different sort order, example a link like /users/recipes?order=created_at, should have
    1. <meta name="robots" content="noindex, noarchive" />

    in their head element.

  6. Your stylesheets, javascript files, images used for styling purposes, non-important pages like sign in, join, privacy policy, terms, should all not be indexed. To ensure this, create a robots.txt file like the following
    # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
    User-Agent: *
    Disallow: /account
    Disallow: /session
    Disallow: /images/
    Disallow: /stylesheets/
    Disallow: /javascripts/
    Disallow: /flash/
    Disallow: /opensearch.xml
    Disallow: /404.html
    Disallow: /500.html
    
    Allow: /

Sign up for Google Webmaster and Yahoo Site Explorer, and add your sites to them, and authenticate that your are the owner of it. Both tools provide very valuable information in optimizing a site for search engines.