Life In The Stack Trace...

TODO: <Insert clever marketing phrase here>

Multiple Sitemap Definitions

Defining multiple sitemaps is very easy. All you need to do is encapsulate your named routes into sitemap blocks with different names. There is no limit to the number of different sitemaps you can create.

The following is taken directly out of the demo Rails app found in the support files.

TestCom::Application.routes.draw do

  root to: 'home#index'

  sitemap :computers do
    resources :desktops
    resources :laptops
    resources :printers
    resources :scanners

  sitemap :office do
    resources :chairs
    resources :desks
    resources :lamps


Here you can see that we are directly defining two separate sitemaps: office and computers. However, three sitemaps are actually available.

  • default: viewable at: /sitemap.xml and contains:
    • root
  • computers: viewable at: /computers.xml and contains:
    • desktops
    • laptops
    • printers
    • scanners
  • office: viewable at: /office.xml and contains:
    • chairs
    • desks
    • lamps

We never redefined the default sitemap with a block, so, all of the routes outside of any sitemap blocks are included in the default sitemap.

Download the support file, expand and look at

sudo bundle install
rake db:migrate
rake db:seed
rails s

The home page has links to all of the sitemaps and they should contain sample urls if you run: rake db:seed