Last active
October 22, 2019 14:20
-
-
Save danhalliday/ee0944a55bae083133525d025fa8a884 to your computer and use it in GitHub Desktop.
Quick-and-dirty sitemap for Middleman.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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