Kristian Glass - Do I Smell Burning?

Mostly technical things

Switching to Atom Summaries in Octopress

I really like Brandon Mathis’s Octopress as a blogging framework.

One of the many useful features is the ability to mark a break-point in a post with a more comment, so the preceding section is used as a preview excerpt on the index page.

The Atom feed generated by Octopress uses the full post content. If you instead want to switch it to only display the summary excerpt (particularly useful if you’ve used it for content warnings) you’ll need two changes to source/atom.xml:

  1. Use the excerpt liquid filter provided by Octopress
  2. Switch out the <content> element for a <summary> element

Here’s my diff:

$ git diff
diff --git a/source/atom.xml b/source/atom.xml
index 83af3f8..5a06d48 100644
--- a/source/atom.xml
+++ b/source/atom.xml
@@ -21,7 +21,7 @@ layout: nil
     <link href="{{ site.url }}{{ post.url }}"/>
     <updated>{{ | date_to_xmlschema }}</updated>
     <id>{{ site.url }}{{ }}</id>
-    <content type="html"><![CDATA[{{ post.content | expand_urls: site.url | cdata_escape }}]]></content>
+    <summary type="html"><![CDATA[{{ post.content | excerpt | expand_urls: site.url | cdata_escape }}]]></summary>
   {% endfor %}