Skip to content

gizm0duck/happy_seo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HappySeo
========

This plugin is intended as a simple way for small sites that want basic search engine friendly urls and keyword/description meta tags.


Example
=======

Basic Usage

  To use happy_seo for a model just declare it as such inside the class
  
  class Author < ActiveRecord::Base
    has_many :books

    happy_seo
  end
  
  Using it:

  >> joel = Author.find_by_name('Joel Salatin')
  => #<Author id: 2, name: "Joel Salatin", description: "Joel F. Salatin (born 1957) is an American farmer, ...", tags: "smart, opinionated, honest, clever, determined", created_at: "2009-04-19 03:31:11", updated_at: "2009-04-19 03:31:11">

  >> joel.seo_id
  => "2-joel-salatin"

  >> joel.meta_keywords
  => "Joel Salatin, smart, opinionated, honest, clever, determined"

  >> joel.meta_description
  => "Joel F. Salatin (born 1957) is an American farmer, lecturer, and author whose books include You Can Farm and Salad Bar Beef. Salatin raises livestock using holistic methods of animal..."

  You can define what the attributes used for each method is on a per model basis, or on a per call basis

  >> joel.meta_description
  => "Joel F. Salatin (born 1957) is an American farmer, lecturer, and author whose books include You Can Farm and Salad Bar Beef. Salatin raises livestock using holistic methods of animal..."
  
  The plugin will even generate a to_param method for your object utilizing the seo_id that you have configured for it, so 
  your link_to methods will automatically begin to utilize the improved seo url's
  
  >> <%= link_to author.name, author %>
  => '/authors/2-joel-salatin'

Modifying the Attributes from the Defaults

  You can choose to either adjust the values for the either on the fly as you are calling it, or configure
  it such that all instances of a particular model behave the same.

  One Time Use

    >> joel.meta_description([:tags, :name])
    => "smart, opinionated, honest, clever, determined. Joel Salatin"
    >> joel.meta_description
    => "Joel F. Salatin (born 1957) is an American farmer, lecturer, and author whose books include You Can Farm and Salad Bar Beef. Salatin raises livestock using holistic methods of animal..."

  Model Wide Use

    def Author.meta_description_attributes
      [:name, :tags]
    end

    joel.meta_description
    => "Joel Salatin. smart, opinionated, honest, clever, determined"
    
For more information on how to use it check out the specs inside the spec directory of the plugin, or read the code, there's not much to it :)

Copyright (c) 2009 Shane Wolf, released under the MIT license

About

Making SEO for small Ruby on Rails sites fun and easy

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages