Recently I rebuilt my blog on Jekyll, a sweet static site generator. However when a friend noticed I had no way for him to subscribe to my content, he suggested adding an RSS feed.
Turns out adding an RSS feed to a Jekyll site is SUPER SIMPLE by just using jekyll-rss-feeds. Here’s how:
1. Add site details for your Jekyll config file
Add the following key/value pairs to your _config.yml
file:
These values will be used as site info in your feed. As a bonus, you can now access these as variables anyplace else in your Jekyll templates by using {{ site.name }}
, {{ site.description }}
and {{ site.url }}
.
2. Add feed.xml
to the site root
The jekyll-rss-feeds project includes several options for types of feeds you can use, including a category feed. But we’re just going to keep it simple.
The following jekyll template will generate a properly formatted list of your 10 most recent posts. Just create a feed.xml
file in your site root, and paste this into it:
If you wish to increase the number of posts that are output in your feed, just modify the integer in the following line that reads { for post in site.posts limit:10 }
from 10
to whatever output you wish.
3. Build your site and push
Yup, that’s it! Just jekyll build
your site and push, or if you are on GitHub Pages, just push your changes to master and your new RSS feed will be in place.
Don’t forget to put a link to your feed somewhere where in your page layout so your readers will know about it and be able to find it.
Also, it’s a good idea to add a <link>
element in the document <head>
for browsers that have built in support for RSS feed-readers. You can use a line like this: <link href='http://joelglovier.com/feed.xml' rel='alternate' type='application/atom+xml'>
(props to @pengwynn for pointing this one out with a PR).
Mad props to @snaptortoise for creating these simple and easy to use RSS Jekyll templates!
How to add an RSS feed to your @Jekyllrb blog in 3 simple steps: http://t.co/PHDHMVfTbc
— Joel Glovier (@jglovier) December 20, 2013