Lego2012
9/26/2016 - 9:12 PM

Create a Sitemap in 2 Steps

Create a Sitemap in 2 Steps

<!--
For sites and blogs with posts that are accessed directly by their html pages,
ie. http://example.com/my-blog-post.html or http://example.com/blog/my-blog-post.html, use:
-->

---
# Remember to set production_url in your _config.yml file!
title : Sitemap
sitemap_exclude: y
---

{% for page in site.pages %}
  {% if page.sitemap_exclude != 'y' %}
    {{site.production_url}}{{ page.url | remove: '/index.html' }}
  {% endif %}
{% endfor %}

{% for post in site.posts %}
  {{site.production_url}}{{ post.url }}
{% endfor %}

<!-- 
In the example above, /index.html is removed from the site's root url in the sitemap, so the homepage is listed as http://example.com instead of http://example.com/index.html.

For blogs with posts that go into folders and are accessed via the folder, ie. http://example.com/my-blog-post/ file, (you may want to also remove the index.html or /index.html depending on your setup) use: 
-->

---
# Remember to set production_url in your _config.yml file!
title : Sitemap
sitemap_exclude: y
---

{% for page in site.pages %}
  {% if page.sitemap_exclude != 'y' %}
    {{site.production_url}}{{ page.url | remove: '/index.html' }}
  {% endif %}
{% endfor %}

{% for post in site.posts %}
  {{site.production_url}}{{ post.url | remove: 'index.html' }}
{% endfor %}

<!-- 
2) Add sitemap_exclude: y to the front-matter of any pages you don't want included in the sitemap. 
-->