Skip to content

Instantly share code, notes, and snippets.

@boennemann
Created May 10, 2013 10:58
Show Gist options
  • Save boennemann/5553735 to your computer and use it in GitHub Desktop.
Save boennemann/5553735 to your computer and use it in GitHub Desktop.
Example for an automatically generated sitemap with jekyll.
---
# Remember to set production_url in your _config.yml file!
layout: nil
title : Sitemap
---
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
{% for page in site.pages %}
<url>
<loc>{{site.production_url}}{{ page.url }}</loc>
</url>
{% endfor %}
{% for post in site.posts %}
<url>
<loc>{{site.production_url}}{{ post.url }}/</loc>
</url>
{% endfor %}
</urlset>
@jruzafa
Copy link

jruzafa commented Sep 21, 2013

It works correctly they but I also added the url to sitemap.xml, I've solved this in the following way.Thanks

{% for page in site.pages %}

    {% if page.url != '/sitemap.xml' %}
      <url>
        <loc>{{site.production_url}}{{ page.url }}</loc>
      </url>
    {% endif %}
{% endfor %}

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