Skip to content

SitemapGenerator Usage

ehoch edited this page Sep 29, 2012 · 29 revisions

SitemapGenerator Usage Examples

Please add your name, site and how many links in your Sitemap, and, if you feel like it, a small snippet of cool code, showing how SitemapGenerator made your life easier.


Adam Salter, www.answermyoffice.com, 72,956 links, 2m03s


Zipcode.find(:all, :include => :city).each do |z|
  sitemap.add zipcode_path(:state => z.city.state, :city => z.city, :zipcode => z)
end

Rob Biedenharn, stylepath.com, Sitemap stats: 4,684,358 links, 6h21m31s

Old: Sitemap stats: 78,645 links, 3m37s

New: Sitemap stats: 4,684,358 links, 6h21m31s


  Category.find_in_order.each do |category|
    sitemap.add category_page_path(category), :changefreq => 'daily', :priority => 0.6
    Product.interesting_from_category(category.id, 0, nil, true).each do |product|
      sitemap.add details_id_path(product), :changefreq => 'weekly', :priority => 0.5
    end
  end

And running against a Rails 1.2.2 project. Only a few changes needed:

  • Need to provide a String#present? (which was easy since I already had String#nonblank?)
  • Cope with the change from app/controllers/application.rb to app/controllers/application_controller.rb by adding:
    • require 'app/controllers/application' to lib/sitemap_generator/helper.rb

mattmueller, 1.9 million urls

It took about 2 hours to generate on a very powerful production server without niceing it. If you decide to nice it (we tried at 15) for that sort of load it would take > 8 hours


openc, 104+million urls for OpenCorporates

Takes several days to generate. Runs weekly on worker server (also processes Resque jobs), and then SCP’d to shared folder on app server, which is symlinked from production.


Since my main sitemap takes too long for Google to process, I take advantage of sitemap_generator’s multiple config option. I generate smaller sitemaps for rapidly changing content such as news.