To those who are using Jekyll for blogging on their websites: this post is about how I created a specific blog feed in mine. Indeed sometimes, you may want to subscribe to a blog aggregator that only accepts a given subject, and still be able to blog about other subjects.

I found Jekyll to be helpful for adding numerous features on my website from scratch. Among those features, I created this blog , which used to be a monolithic HTML page. Of course, if you’re not into programming, there are many commercial drag-and-drop alternatives out there.

Liquid is the programming language used for our purpose, in combination with xml. Liquid looks and feels like Ruby, a programming language that I love, and a concise documentation of this dialect can be found online.

The first step is to create blog categories in each post available in _posts/ that you’d want to be categorized. For the post you’re reading now, it’s category Misc.

image-title-here

If there are more than one categories for a given post, it would be instead something as:

categories: [cat1, cat2]

Then in your blog’s configuration file _config.yml, you’ll need to declare that links to each post contain information about their categories too:

image-title-here

Having added categories in posts and modified the configuration file, now create a file feed_cat.xml in website’s root, where cat is the category of interest for the aggregator. In my case, I created feed_R.xml manually, with the following content excerpt:

image-title-here

In the source file feed_R.xml, <xml> tags indicates that it’s a .xml file, with english characters encoding. Our feed is delimited by <feed> tags, and each post content by <entry> tags. In the file’s body, I loop through all the categories available on my website, filter on category “R”, and fetch blog posts available in this category – limited to 5 posts fetched. I stop looping on categories as soon as the category of interest is found and its 5 most recent posts are fetched.

For more details into what each instruction in feed_R.xml does, you can refer to Liquid docs and xml tutorial. And if there’s any other way of doing what we just did, I’d be happy to hear about it. Once feed_cat.xml’s been created in website’s root, you should verify your feed’s syntax with this online tool – otherwise, it may not work:

https://validator.w3.org/feed/

If everything in the syntax is fine, you should get a message like the one below:

image-title-here

You can now submit feed_cat.xml to the aggregator interested in cat.