Skip to content

Instantly share code, notes, and snippets.

@vraravam
Created February 21, 2015 18:02
Show Gist options
  • Save vraravam/7b0b4adda5a2fbc8d3bd to your computer and use it in GitHub Desktop.
Save vraravam/7b0b4adda5a2fbc8d3bd to your computer and use it in GitHub Desktop.
Using sitemap_generator gem and configuring it to generate pages from high_voltage
# Set the host name for URL creation
SitemapGenerator::Sitemap.default_host = 'http://www.pycosystems.com'
SitemapGenerator::Sitemap.create do
# Put links creation logic here.
#
# The root path '/' and sitemap index file are added automatically for you.
# Links are added to the Sitemap in the order they are specified.
#
# Usage: add(path, options={})
# (default options are used if you don't specify)
#
# Defaults: priority: 0.5, changefreq: 'weekly',
# lastmod: Time.now, host: default_host
#
# Examples:
#
# Add '/articles'
#
# add articles_path, priority: 0.7, changefreq: 'daily'
#
# Add all articles:
#
# Article.find_each do |article|
# add article_path(article), lastmod: article.updated_at
# end
all_pages = Dir.entries(Rails.root.join('app', 'views', HighVoltage.content_path)).map { |page| Rails.application.routes.url_helpers.page_path(page.gsub('.html.erb', '')) if page =~ /.html.erb$/ && page !~ /coming_soon|home/ }.compact
all_pages << Rails.application.routes.url_helpers.trainings_path
all_pages.sort.each do |page|
add(page, priority: 1.0, changefreq: 'weekly')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment