A human-readable RSS feed with Jekyll
I refactored my RSS feed using Jekyll functionalities, applying XSLT for presentation to render a human-readable XML feed.
Skills
- Jekyll
- Liquid
- HTML
- CSS
- XML
- XSLT
Objectives
I recently stumbled on an article,1 where two things caught my eye: styled OPML blogrolls that can be directly imported into an RSS reader, and styled RSS feeds. I had forgotten about XSLT with its potential applications, so the above examples inspired me. Also, I wasn't aware that OPML, which I’ve been using for years to import and export RSS feeds, could be styled. This prompted me to refactor my RSS feed, and give a human readable format to it, consistent with the website.
Approach
I created a loop that could exploit the layout type rather than the content type, because I tend to add and remove collections to my site, and this is a more flexible solution. The loop iterates 20 times (my configuration value for posts_limit) through the resulting variable.
{% assign blog = site.documents | where:"layout", "post" | sort: 'date' | reverse %}
{% for post in blog limit:site.posts_limit %}
<item>
[code here]
</item>
{% endfor %}
Then, I created an XSL file to style the feed page into a human readable format. Since I was rewriting the RSS feed from scratch, I added a few features:
- a brief personal introduction at the top of the main feed;
- author information directly in each post, for easy contact information;
- a "reply via email" link at the end of each post, visible on any RSS reader.
Before

After

Results
It was surprisingly easy, and I wonder why didn't I do it sooner. Since my main motivation for leaving WordPress was to take full control over my code, I should have managed the feed myself rather than relying on a Jekyll plug-in. The source code for the RSS XML feed and the XLS file are available on Github.
Footnotes
-
Cool Things People Do With Their Blogs by Wouter Groeneveld. ↩