Skip to content

Instantly share code, notes, and snippets.

@danhalliday
Last active October 22, 2019 14:20
Show Gist options
  • Save danhalliday/ee0944a55bae083133525d025fa8a884 to your computer and use it in GitHub Desktop.
Save danhalliday/ee0944a55bae083133525d025fa8a884 to your computer and use it in GitHub Desktop.
Quick-and-dirty sitemap for Middleman.
xml.instruct!
xml.urlset "xmlns" => "http://www.sitemaps.org/schemas/sitemap/0.9" do
sitemap.resources.select { |page| page.destination_path =~ /\.html/ && page.data.noindex != true }.each do |page|
xml.url do
modified = page.data.date ? page.data.date.to_time : Time.now
xml.loc URI.join(data.site.host, page.destination_path.chomp("index.html").chomp(".html"))
xml.lastmod modified.iso8601
xml.changefreq page.data.changefreq || "monthly"
xml.priority page.data.priority || "0.5"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment