Build Status

Sitemap Notifier

Sitemap Notifier is a Ruby on Rails plugin that, when installed, automatically notifies Google, Bing, and Yahoo of changes to your models, i.e. changes to your sitemap. It also works in conjunction with the dynamic_sitemaps plugin.


In your Gemfile:

gem 'sitemap_notifier'

And run:

$ bundle install


Start by generating an initializer:

$ rails generate sitemap_notifier:install

Then, in config/initializers/sitemap_notifier.rb:

SitemapNotifier::Notifier.configure do |config|
  # Set URL to your sitemap. This is required.
  # This can also be configured per model basis,
  # see
  config.sitemap_url = ""

  # Models that should trigger notification of search engines
  config.models = [Article, Category]

  # Enabled in which environments – default is [:production]
  config.environments = [:development, :production]

  # Delay to wait between notifications – default is 10 minutes
  config.delay = 2.minutes

  # Additional urls to ping
  config.ping_urls << "http://localhost:3000/ping?sitemap=%{sitemap_url}"

Then create or update a model:

Article.create :title => "My New Article"

The search engines are then automatically notified.

After installation

After you install and configure the plugin, it'll automatically notify Google, Bing, and Yahoo every time you update a model. After each notification, it'll wait 10 minutes (by default) before notifying again. This is to ensure that for example a batch update won't trigger an equal amount of notifications.


Per model sitemap URL

The sitemaps defaults to what you set in SitemapNotifier::Notifier.sitemap_url. If you want to use a different sitemap URL based on data in your models, you can override the sitemap_url method of each of your models like this:

class Product < ActiveRecord::Base
  belongs_to :site

  def sitemap_url

Conditional notifications

You can decide on model level whether the search engines should be pinged by overriding the notify_sitemap? method of your models:

class Product < ActiveRecord::Base
  belongs_to :site

  def notify_sitemap? == 1

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