0

Middleman can show a sitemap under its config url when a local server is running. When publishing the static site to a CDN I cannot find anyway to access this sitemap, and I'd like to have it there for SEO purposes. I've assumed up to this point middleman includes the sitemap in the build, but I cannot find it now that I look. Assuming that's true, how can I publish the sitemap online?

James L.
  • 12,893
  • 4
  • 49
  • 60

1 Answers1

1

While I'm a bit of a Middleman newbie, and haven't gotten around to adding a sitemap to my Middleman site, my friend uses the Middleman Search Engine Sitemap gem to generate a sitemap in his sites.

Another solution that I have seen is to use a Builder file to generate the sitemap:

Create a source file: source/sitemap.xml.builder.

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
      xml.loc URI.join(settings.casper[:blog][:url], page.destination_path)
  last_mod = if page.path.start_with?('articles/')
        File.mtime(page.source_file).to_time
      else
        Time.now
      end
      xml.lastmod last_mod.iso8601
      xml.changefreq page.data.changefreq || "monthly"
     xml.priority page.data.priority || "0.5"
   end
 end
end
Speedy1812
  • 61
  • 5
  • Awesome thanks! I found [this gem](https://github.com/statonjr/middleman-sitemap) (which has better SEO) at first, but it's broken in current middleman. Then I got the builder set up, but didn't know about the other gem. I'll try including that instead in order to simplify things. – James L. May 09 '17 at 19:55