Skip to content

Instantly share code, notes, and snippets.

@pathawks
Created November 5, 2011 20:58
Show Gist options
  • Save pathawks/1342013 to your computer and use it in GitHub Desktop.
Save pathawks/1342013 to your computer and use it in GitHub Desktop.
Simple Jekyll feed

Jekyll Feed

A safe way to add an Atom feed to a Jekyll site

In _config.yml you should define the following

  • url
  • title
  • owner
  • owner_email
---
layout: nil
---
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
{% if site.url %}
{% assign siteURL = site.url %}
{% else %}
{% assign siteURL = site.root %}
{% endif %}
<title>{{ site.title }}</title>
<link href="{{ siteURL }}/atom.xml" rel="self"/>
<link href="{{ siteURL }}/"/>
<updated>{{ site.time | date_to_xmlschema }}</updated>
<id>{{ siteURL }}/</id>
<author>
<name>{{ site.author }}</name>
<email>{{ site.email }}</email>
</author>
{% for post in site.posts %}
{% unless post.hide %}
<entry>
<title>{{ post.title }}</title>
<link href="{{ siteURL }}{{ post.url }}"/>
<updated>{{ post.date | date_to_xmlschema }}</updated>
<id>{{ siteURL }}{{ post.id }}</id>
<content type="html">{{ post.content | xml_escape }}</content>
</entry>
{% endunless %}
{% endfor %}
</feed>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment