SEO

Generating Sitemaps in Rails

Code updated 9/18/2009

This week I added sitemap files to my rails site PriceChirp. Sitemaps are used to help search engines to find all your content. They are especially helpful in enumerating pages that are difficult for web crawlers to discover, such as content from database searches.

The web is full of instructions on how to generate sitemaps on the fly using rxml templates. This does not scale well if your site has thousands of links. A better method is to periodically generate site maps and serve these cached files when requested.

www.fortytwo.gr has a good example for generating sitemaps with rails. I've taken his code and fixed/extended it to fit my needs.

Understanding Sitemaps

Google's sitemap howto.

Basically, there are two types of sitemap files:

Syndicate content