Skip to content

Instantly share code, notes, and snippets.

@keith
Last active December 19, 2015 11:59
Show Gist options
  • Save keith/5951329 to your computer and use it in GitHub Desktop.
Save keith/5951329 to your computer and use it in GitHub Desktop.
Jekyll Atom Feed
---
layout: nil
---
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title type="text"><![CDATA[{{ site.name }}]]></title>
{% if site.description %}
<subtitle type="text"><![CDATA[{{ site.description }}]]></subtitle>
{% endif %}
<updated>{{ site.time | date_to_xmlschema }}</updated>
<id>{{ site.url }}/</id>
<link rel="alternate" type="text/html" hreflang="en" href="{{ site.url }}" />
{% if site.feed %}
<link rel="self" type="application/atom+xml" href="{{ site.url }}{{ site.feed }}" />
{% endif %}
<rights>Copyright (c) {{ site.time | date: "%Y" }} {{ site.author }}</rights>
<generator uri="http://jekyllrb.com/" version="1.0.3">Jekyll</generator>
{% for post in site.posts %}
<entry>
<title type="html"><![CDATA[{{ post.title }}]]></title>
<link rel="alternate" type="text/html" href="{{ site.url }}{{ post.url }}" />
<id>{{ site.url }}{{ post.id }}</id>
<updated>{{ post.date | date_to_xmlschema }}</updated>
<author>
{% if post.author %}
<name><![CDATA[{{ post.author }}]]></name>
{% else %}
<name><![CDATA[{{ site.author }}]]></name>
{% endif %}
</author>
<content type="html">
<![CDATA[{{ post.content }}]]>
</content>
</entry>
{% endfor %}
</feed>

Place this file in the root directory of your Jekyll site. Name it something like atom.xml.

In _config.yml:

  • A url key ex: url: http://smileykeith.com No trailing slash
  • An author key ex: author: Keith Smiley

Optional:

  • A feed key for the URL of the ATOM file ex: feed: /atom.xml
  • A description key for the description in the ATOM feed
  • A per-post author key for different authors per post
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment