Skip to content

Instantly share code, notes, and snippets.

@alexbaldwin
Forked from jnbt/sitemap.xml.erb
Created April 13, 2013 01:28
Show Gist options
  • Save alexbaldwin/5376440 to your computer and use it in GitHub Desktop.
Save alexbaldwin/5376440 to your computer and use it in GitHub Desktop.
<% base_url = "http://youdomain.com/" %>
<% pages = sitemap.resources.find_all{|p| p.source_file.match(/\.html/) } %>
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<% pages.each do |p| %>
<url>
<loc><%= base_url + p.destination_path.gsub('index.html','') %></loc>
<% if priority = p.metadata[:page]['priority'] %>
<priority><%= priority %> </priority>
<% end %>
<lastmod><%= File.new(p.source_file).mtime.to_date %></lastmod>
</url>
<% end %>
</urlset>
@alexbaldwin
Copy link
Author

Don't forget to add

page "/sitemap.xml", :layout => false

to your config.rb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment