Recently I moved my blog to Jekyll, while being able to write stuff directly in my favorite editor EMACS, there was some functionality that I was missing from my previous custom blog engine, such as archives. Looking at how I could achieve this, I found Raoul Felix approach to the problem. Instead of patching jekyll, he wrote a small library that wraps around it, called jekyll_ext. Using it was really easy, and based on some of the extensions he created, I was able to provide this functionality in my site.
Although I had archives generated for me, I was still missing a way to display this information on my site, so I decided to create my own extension.
I added the following code inside _extensions/archive_iterator.rb, which will provide me with an array of all the months when I’ve written posts:
The information for the archive was gathered from the archive_gen extension, although I had to slightly modify. Instead of processing the information after render, I had to do it before rendering, so the information would be available when the pages are created, like this:
Then inside my layout I was able to easily display this information like this:
Note the extra space between ‘{‘ and ‘%’, this is to avoid liquid interpreting the code inside the tags. You can view all the source code here.