Skip to content

Instantly share code, notes, and snippets.

@metaskills
Created October 19, 2011 11:40
Show Gist options
  • Save metaskills/1298052 to your computer and use it in GitHub Desktop.
Save metaskills/1298052 to your computer and use it in GitHub Desktop.
An example of a site map.xml in Jekyll

A Sitemap.xml Template

---
layout: nil
---
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:image="http://www.sitemaps.org/schemas/sitemap-image/1.1"
        xmlns:video="http://www.sitemaps.org/schemas/sitemap-video/1.1">
  {% for post in site.posts %}
  <url> 
    <loc>http://metaskills.net{{ post.url }}</loc> 
    {% if post.lastmod %}
    <lastmod>{{ post.lastmod | date_to_xmlschema }}</lastmod>
    {% else %}
    <lastmod>{{ post.date | date_to_xmlschema }}</lastmod>
    {% endif %}
  </url>
  {% endfor %}
</urlset>

Usage

Put a optional lastmod date in your YAML front matter.

--- 
layout: post
title: Authenticated S3 GETs For Private Objects Using Paperclip
lastmod: 2011-10-18
...
---

Result

Would look something like this.

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.sitemaps.org/schemas/sitemap-image/1.1" xmlns:video="http://www.sitemaps.org/schemas/sitemap-video/1.1">
  ...
  <url>
    <loc>http://metaskills.net/2009/11/23/authenticated-s3-gets-for-private-objects-using-paperclip</loc>
    <lastmod>2011-10-18T00:00:00+00:00</lastmod>
  </url>
  <url>
    <loc>http://metaskills.net/2009/11/11/meta-programming-in</loc>
    <lastmod>2009-11-11T00:00:00-05:00</lastmod>
  </url>
  ...
</urlset>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment