thoughtbot / middleman-template

The base Middleman application used at thoughtbot, ready to deploy to Netlify.
https://thoughtbot.com
MIT License
86 stars 35 forks source link

Add sitemap #23

Closed tysongach closed 7 years ago

tysongach commented 7 years ago

This builds a proper sitemap.xml file at the root of the website. It aids in SEO, telling search engines about the organization of the site's content.

https://support.google.com/webmasters/answer/156184

The URL environment variable gives us an easy global way of accessing the site's URL, for use in the sitemap and anywhere else. Netlify provides some pre-defined variables, including URL, which "represents the main address to your site". Using this means we won't need to set the variable manually in the Netlify settings.

https://www.netlify.com/docs/continuous-deployment/#build-environment-variables

jasonramirez commented 7 years ago

@tysongach the code looks fine, but I am not familiar with how this works, so I can't make any comment to the efficacy of the code.

tysongach commented 7 years ago

Thanks for taking a look. Basically, it leverages Middleman's sitemap (a feature of Middleman, not the end product) to loop through all pages of the website and generate the XML sitemap. It's how Middleman's own website does it: https://github.com/middleman/middlemanapp.com/blob/master/source/sitemap.xml.builder

Given that this code is also successfully working on AccessLint's website, as well as Bourbon's, I'm going to go ahead and merge.