Skip to content

Instantly share code, notes, and snippets.

Created December 19, 2012 22:39
Show Gist options
  • Save anonymous/4341222 to your computer and use it in GitHub Desktop.
Save anonymous/4341222 to your computer and use it in GitHub Desktop.
rewrite ^/sitemap1.xml.gz /sitemaps/$host/sitemap1.xml.gz last;
rewrite ^/sitemap_index.xml.gz /sitemaps/$host/sitemap_index.xml.gz last;
require 'rubygems'
require 'sitemap_generator'
Constants::HOSTS.each do |host, locale|
SitemapGenerator::Sitemap.default_host = "http://#{host}"
SitemapGenerator::Sitemap.public_path = "public/sitemaps/#{host}"
SitemapGenerator::Sitemap.sitemaps_path = ''
SitemapGenerator::Sitemap.create do
add root_path, priority: 1
Property.find_each do |property|
add property_path(property),
priority: 0.8,
lastmod: (property.updated_at || property.created_at),
alternates: Constants::HOSTS.map { |h, l|
if locale != l
{
href: property_url(property, host: h),
lang: l
}
end
}.compact
end
end
SitemapGenerator::Sitemap.ping_search_engines
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment