RSS Feeds and Jekyll

Configuring RSS Feed and implementing into Jekyll

RSS Feeds and Jekyll

by John Vincent

Posted on May 1, 2017

RSS can seem so mystical. Let's set up an RSS feed and implement into Jekyll.

RSS (Rich Site Summary, or Really Simple Syndication) is a type of web feed which allows users to access updates to online content in a standardized, computer-readable format.

Configuring RSS Feed with Jekyll is straightforward. Let us begin.


Create file feed.xml in source folder

layout: null
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="">
    <title>{{ site.title | xml_escape }}</title>
    <description>{{ site.description | xml_escape }}</description>
    <link>{{ site.url }}{{ site.baseurl }}/</link>
    <atom:link href="{{ "/feed.xml" | prepend: site.baseurl | prepend: site.url }}" rel="self" type="application/rss+xml"/>
    <pubDate>{{ site.time | date_to_rfc822 }}</pubDate>
    <lastBuildDate>{{ site.time | date_to_rfc822 }}</lastBuildDate>
    <generator>Jekyll v{{ jekyll.version }}</generator>
    {% for post in site.posts limit:1000 %}
    {% if post.sitemap != false %} 
        <title>{{ post.title | xml_escape }}</title>
        <description>{{ post.content | xml_escape }}</description>
        <pubDate>{{ | date_to_rfc822 }}</pubDate>
        <link>{{ post.url | prepend: site.baseurl | prepend: site.url }}</link>
        <guid isPermaLink="true">{{ post.url | prepend: site.baseurl | prepend: site.url }}</guid>
        {% for tag in post.tags %}
        <category>{{ tag | xml_escape }}</category>
        {% endfor %}
        {% for cat in post.categories %}
        <category>{{ cat | xml_escape }}</category>
        {% endfor %}
      {% endif %}
    {% endfor %}

Will generate a feed.xml file. Push code to production.

Jekyll Changes

Add to every page

<link rel="alternate" type="application/rss+xml" href="{{ site.url }}/feed.xml" />

I already have Font Awesome Icons and so I added a link with

    <a href="{{ site.url }}/feed.xml"><i class="fa fa-rss" aria-hidden="true"></i></a>

Validate RSS Feed File

The RSS Feed file must be correctly formatted. To verify, use a Validator

Ensure all problems are fixed before proceeding.

The default Content-Type for feed.xml is text/xml

The Content-Type needs to application/rss+xml

Get Response Headers

To verify Content-Type

wget -q -S -O - > /dev/null

Nginx Change for RSS Feeds

Add the following to the server block

location = /feed.xml {
    types        { }
    default_type "application/rss+xml";

Restart Server

sudo nginx -t
sudo systemctl reload nginx
sudo systemctl restart nginx

Get the response headers to verify the type is now correct.

Exclude from feed.xml

Add to post yml

sitemap: false
JSBinGoogle Maps APIs