SitemapGenerator plugin

Plugin details

This plugin enables 'enterprise-class' Google Sitemaps to be easily generated for a Rails site as a rake task, using a simple 'Rails Routes'-like DSL. It allows you to take care of familiar Sitemap issues like: Gzip of Sitemap files, variable priority links, paging/sorting links (e.g. my_list?page=3), SSL host links (e.g. https:), Rails apps which are installed on a sub-path (e.g. example.com/blog_app/) and hidden AJAX routes. It includes a Sitemap Index file so it supports more than the standard 50,000 individual urls (up to a maximum of 2.5 billion), and pings all major search engines on completion (Google, Yahoo, MSN, Ask, SitemapWriter).

Websitehttp://github.com/adamsalter/sitemap_generator-plugin/tree/master Repositorygit://github.com/adamsalter/sitemap_generator-plugin.git Author Adam Salter Tags generator, plugin, Google, sitemap LicenseMIT

Documentation

Install the plugin:
ruby script/plugin install git://github.com/adamsalter/sitemap_generator-plugin.git

1. Install plugin as normal

./script/plugin install git://github.com/adamsalter/sitemap_generator-plugin.git



2. Installation should create a 'config/sitemap.rb' file which will contain your logic for generation of the Sitemap files. (If you want to recreate this file manually run `rake sitemap:install`)

3. Run `rake sitemap:refresh` as needed to create Sitemap files. This will also ping all the major search engines.

Sitemaps with many urls (100,000+) take quite a long time to generate, so if you need to refresh your Sitemaps regularly you can set the rake task up as a cron job.

4. Finally, and optionally, add the following to your robots.txt file.

Sitemap: HOSTNAME/sitemap_index.xml.gz



The robots.txt Sitemap URL should be the complete URL to the Sitemap index, such as: `http://www.example.org/sitemap_index.xml.gz`

More details available in README file on GitHub.

Example 'config/sitemap.rb'

# Set the host name for URL creation
SitemapGenerator::Sitemap.default_host = "http://www.example.com"

SitemapGenerator::Sitemap.add_links do |sitemap|
  # Put links creation logic here.
  #
  # The root path '/' and sitemap index file are added automatically.
  # Links are added to the Sitemap in the order they are specified.
  #
  # Usage: sitemap.add path, options
  #        (default options are used if you don't specify)
  #
  # Defaults: :priority => 0.5, :changefreq => 'weekly', 
  #           :lastmod => Time.now, :host => default_host


  # Examples:

  # add '/articles'
  sitemap.add articles_path, :priority => 0.7, :changefreq => 'daily'

  # add all individual articles
  Article.find(:all).each do |a|
    sitemap.add article_path(a), :lastmod => a.updated_at
  end

  # add merchant path
  sitemap.add '/purchase', :priority => 0.7, :host => "https://www.example.com"

end

Further Documentation

Edit plugin | Back in time (9 older versions) | Last edited by: aqsalter, 8 months ago