Skip to content

Latest commit

 

History

History
100 lines (53 loc) · 2.72 KB

README.rdoc

File metadata and controls

100 lines (53 loc) · 2.72 KB

Dynamic Sitemaps is a plugin for Ruby on Rails that enables you to easily create flexible, dynamic sitemaps. It creates sitemaps in the sitemaps.org standard which is supported by several crawlers including Google, Bing, and Yahoo. If the sitemap has more than 50.000 urls – or whatever you set it to using per_page – the plugin will automatically split the sitemap into smaller chunks and generate a sitemap index, also specified at sitemaps.org.

Installation

In your Gemfile:

gem 'dynamic_sitemaps'

Then run bundle install.

Example

Start by generating initializer and route:

$ rails generate dynamic_sitemaps sitemap

In config/initializers/sitemap.rb:

DynamicSitemaps::Sitemap.draw do

  # default page size is 50.000 which is the specified maximum at http://sitemaps.org.
  per_page 10

  url root_url, :last_mod => DateTime.now, :change_freq => 'daily', :priority => 1

  new_page!

  Product.all.each do |product|
    url product_url(product), :last_mod => product.updated_at, :change_freq => 'monthly', :priority => 0.8
  end

  new_page!

  autogenerate  :products, :categories,
                :last_mod => :updated_at,
                :change_freq => 'monthly',
                :priority => 0.8

  new_page!

  autogenerate  :users,
                :last_mod => :updated_at,
                :change_freq => lambda { |user| user.very_active? ? 'weekly' : 'monthly' },
                :priority => 0.5

end

Then go to yourdomain.com/sitemap.xml in your browser.

Installing the sitemap

In public/robots.txt:

Sitemap: http://yourdomain.com/sitemap.xml

This will enable crawlers to find your sitemap.

Submitting the sitemap to crawlers

Google

  1. Go to Google Webmaster Central at www.google.com/webmasters/ and sign in

  2. Click “Add a site…” and follow instructions for adding your site and verify ownership

  3. Go to Site configuration > Sitemaps and click “Submit a Sitemap”

  4. Type in sitemap.xml – no domain is needed as this is locked to your current website

  5. Click “Submit Sitemap”

Google will now download and use your sitemap.

Bing

Go to Webmaster Tools at www.bing.com/toolbox/webmasters/ and follow instructions.

Yahoo

Go to Site Explorer at siteexplorer.search.yahoo.com/ and follow instructions.

Notifying search engines with changes to the sitemap

If you want to notify search engines with changes to your sitemap, see the Sitemap Notifier (github.com/lassebunk/sitemap_notifier) plugin.

Contributors

  • Lasse Bunk (creator)

  • Aubrey Goodman

Copyright © 2010-2011 Lasse Bunk, released under the MIT license