Simple Rss Feed With Jekyll

under Programming Jekyll

 

With moving my site off of Wordpress, I landed on Jekyll, but wanted to add an RSS feed option. Here is a simple way, without plugins. One of its example Generator plugins for Jekyll is their jekyll-feed plugin, used as a reference for those creating similar style file generation. Since I am Gemfile less currently, I really didnt want to add another configuration item, and it dawned on me…just build the RSS feed using templates and liquid!

Below is an example of just that, a template for atom 2.0 formatted post list.

 

---
# https://validator.w3.org/feed/docs/atom.html
permalink: /feed.xml
---
<feed xmlns="http://www.w3.org/2005/Atom">
	<title>{{ site.title }}</title>
	<subtitle>{{ site.tagline }}</subtitle>
	<link href="{{ site.url}}/feed/" rel="self" />
	<link href="{{ site.url}}" />
	<id>{{ site.url}}</id>
	<updated>{{ site.time | date: '%FT%TZ' }}</updated>
    {% for post in site.posts %}
    <entry>
        <title>{{ post.title | xml_escape}}</title>
        <updated>{{ post.date | date: '%FT%TZ' }}</updated>
        <id>{{ site.url}}{{ post.url }}</id>
        <link>{{ site.url}}{{ post.url }}</link>
        <summary>{{ post.excerpt |  strip_html | xml_escape }}</summary>
    </entry>
    {% endfor %}
</feed>