Ninja Ferret

The random thoughts of a software developer

Creating an Atom Feed on GitHub Pages

Like any good blog I need an feed so that the many people who are addicted to my random ramblings can follow me using their news readers. So, how would I do that?

The atom feed is simply an XML document and the Liquid Templating engine can generate anything that you want so I searched on-line and found some atom samples and used them to generate this Atom feed file:

---
layout: null
---
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>Ninja Ferret</title>
  <link href="http://ninjaferret.github.com/feed.atom" rel="self"/>
  <link href="http://ninjaferret.github.com/"/>
  <updated>{{ site.time | date_to_xmlschema }}</updated>
  <id>http://ninjaferret.github.com</id>
  <author>
    <name>Ian Johnson</name>
    <email>[email protected]</email>
  </author>
  {% for post in site.posts %}
    <entry>
      <title>{{ post.title }}</title>
      <link href="http://ninjaferret.github.com{{ post.url }}"/>
      <updated>{{ post.date | date_to_xmlschema }}</updated>
      <id>http://ninjaferret.github.com{{ post.id }}</id>
      <content type="html">{{ post.content | xml_escape }}</content>
    </entry>
  {% endfor %}
</feed>

And there is it, it's a simple file to create that will build an atom feed for your site.

Tags:

blog comments powered by Disqus