Is there an easy way to create a sitemaps file for Rails projects? Especially for dynamic sites (such as Stack Overflow for example) there should be a way to dynamically cre
I would recommend that you check out the sitemap_generator gem. It handles all of these issues for you...and really, who wants to mess around authoring XML?
Here is an example sitemap to show how you use your Rails models and path helpers to generate your sitemap URLs:
# config/sitemap.rb
SitemapGenerator::Sitemap.default_host = "http://www.example.com"
SitemapGenerator::Sitemap.create do
add '/contact_us'
Content.find_each do |content|
add content_path(content), :lastmod => content.updated_at
end
end
Then you use Rake tasks to refresh as often as you would like. It really is that simple :)