Step 5. Test your sitemap and submit it to Google

At the end, you should see a count of the URL’s in your sitemap. You’re done!

Alternatives

The sitemap above is generated on-the-fly as search engines request it. If your site is particularly huge, you could generate the sitemap on a schedule. This certainly complicates things, but there are gems to help: sitemap_generator, for instance. I evaluated these but found they added too much overhead to the deployment and maintenance processes for a medium-size app.

I had seen a similar write up on Stack Overflow – but your explanation is more complete and worked on my first attempt to follow it. The big thing is to make sure you install the haml-rails gem and that it does not break anything else! Thanks for such a cool article!

What about pages that aren’t tied directly to a model (for example text is supplied from config bars) or pages that contain data from multiple models? It seems this approach would get very complicated very quickly.

That’s a great question, and I don’t have a great answer. Sitemaps are generally meant to expose pages that a search engine would otherwise have a hard time finding. They don’t necessary have to include every page on your site, so long as the pages it doesn’t include are reachable by links from other pages that it does. If you find a better way, please post here!