Skip to main content
100%

Sitemap.xml rake task

✓ Published0🌍 Public
DDylanFM
Last edited Mar 23, 2009
Created on Mar 23, 2009

This example shows a Ruby rake task that programmatically generates a sitemap.xml file for a website. It first assembles a list of page URLs from static routes, database categories, and photos, then builds a valid XML document using the Nokogiri library’s XML builder. The code iterates over all Category and Photo records via ActiveRecord-style queries, constructs full URLs with a hardcoded domain, and writes the resulting XML to the public directory. It demonstrates a common pattern for dynamic sitemap generation in a Merb environment, with the final output counting the number of URLs saved.

AI-generated description

Similar vizzes