Last active
March 10, 2017 18:55
-
-
Save dbtlr/5294990 to your computer and use it in GitHub Desktop.
Sitemap.xml file in HAML 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 version="1.0" encoding="UTF-8"?> | |
- pages = sitemap.resources.find_all{ |page| page.source_file.match(/\.html/) and not page.source_file.match(/source\/test\// ) } | |
-# Fill this array in with pages you don't want in the sitemap. | |
- excluded_paths = ['404'] | |
- host = "http://yoursite.com/" | |
%urlset{ :xmlns => "http://www.sitemaps.org/schemas/sitemap/0.9" } | |
%url | |
%loc= host | |
%priority 0.3 | |
%lastmod= DateTime.now.to_time.iso8601 | |
%changefreq daily | |
- pages.each do |page| | |
- path = page.destination_path.gsub('/index.html','') | |
- unless excluded_paths.include? path | |
- priority = 0.4 | |
- changefreq = 'monthly' | |
- lastmod = '' | |
- article = blog.articles.find {|a| a.url == '/' + path } | |
- if article | |
- lastmod = article.date.to_time.iso8601 if article | |
- priority = 0.2 | |
- changefreq = 'monthly' | |
- lastmod = page.data.lastmod.to_time.iso8601 if page.data.lastmod | |
- changefreq = page.data.changefreq if page.data.changefreq | |
- priority = page.data.priority if page.data.priority | |
%url | |
%loc= host + path | |
%lastmod= lastmod | |
%changefreq= changefreq | |
%priority= priority |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment