Jekyll Collections

Not an epic discovery, but they sure solved a problem.

Jekyll Collections

I was looking for a way to make my audiobooks easily available to my wife, and I found an awesome solution using Jekyll and Jekyll Collections.

Adding a collection to Jekyll will allow you to generate additional feeds, not just the built-in posts feed that Jekyll has right out of the box. With some small additions to your _config.yml, you will be on your way.

Let’s Do It

The first thing to do is to add a collection to your _config.yml file.

Here is the snippet that needs to be added to your config file to create a new collection:

# collections
- audio

This initializes the audio collection. For more documentation on Jekyll Collections, check out the documentation on Jekyll’s site.

Now create a folder named _audio in your Jekyll root, just like the _posts folder. You can then create a markdown document in the _audio folder and Jekyll will pick it up and process it just like it does with markdown files in the _posts folder. You’ll need to set the layout, title, and other variables that you want to use.

My audiobook markdown file consists of the following:

layout: audio
title: "A Book Title"
date: 2016-02-12 12:00:00
author: "Dion Munk"
duration: 01:00:00
description: >
    A description.
file: ""

Make an iTunes RSS Podcast Feed

Now we need to build a template file we can use for a podcast feed and place it in a folder called audio in the Jekyll root folder. You can call the file feed.xml or whatever you want, it really isn’t important as long as you remember what it is.

This is my feed.xml file:

layout: null
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="" xmlns:itunes="" xml:lang="{{ site.lang }}">
        <link>{{ site.url }}</link>
        <copyright>&#169; Dion Munk {{ site.time | date: "%Y" }}. All rights reserved.</copyright>
        <itunes:author>{{ }}</itunes:author>
        <itunes:category text="Audiobooks" />
        <itunes:image href="{{ site.url }}/assets/images/d.png" />
            <link>{{ site.url }}</link>
            <url>{{ site.url }}/assets/images/d.png</url>
            <itunes:name>{{ }}</itunes:name>
            <itunes:email>{{ }}</itunes:email>
        <itunes:subtitle>A collection of audiobooks.</itunes:subtitle>
        <itunes:summary>A collection of audiobooks.</itunes:summary>
        <description>A collection of audiobooks.</description>
        <language>{{ site.lang }}</language>
        {% for audiobook in %}
                <title>{{ audiobook.title | xml_escape }}</title>
                <pubDate>{{ | date_to_rfc822 }}</pubDate>
                <itunes:author>{{ }}</itunes:author>
                <itunes:duration>{{ audiobook.duration }}</itunes:duration>
                <itunes:subtitle>{{ audiobook.title | xml_escape  }}</itunes:subtitle>
                <itunes:summary>{{ audiobook.description | xml_escape }}</itunes:summary>
                <description>{{ audiobook.description | xml_escape }}</description>
                <enclosure url="{{ audiobook.file | xml_escape }}" length="{{ audiobook.length | xml_escape }}" type="audio/mp3"/>
        {% endfor %}

At this point, besides your default Jekyll directory structure, you should have something like this:

|-- _audio
|   `--
`-- audio
    `-- feed.xml

File Hosting

I’m hosting my audiobook files from my Dropbox. With a free Dropbox account, you get 10GB of bandwidth per day, whereas a paid account gets 250GB per day. You aren’t likely to hit either limit if you are privately listening to your books using this method.

If you do host your files on Dropbox, set the file: "" in your audiobook markdown file to its Dropbox link. You can get the link by right-clicking the file on your computer located in your Dropbox folder, and picking Share Dropbox Link. Paste the link into your markdown file and change the dl=0 at the end of the link to dl=1 and you are set.

Accessing Your Feed

Once you’ve deployed your Jekyll site and you’ve got your audiobook file synced to Dropbox, you just need to point your favorite podcasting app at your feed URL. In our example case, it would be something like

categories :  development