Richard Perry

Just another blog about nothing

Converting the Posts Memories: Serbia & Hungary 2006...

Tweaking Jekyll to Suit My Needs

  |     |   Technology, Jekyll

Migrating to Jekyll

  1. Moving from WordPress to Jekyll
  2. Planning the Migration
  3. Converting the Posts
  4. Tweaking Jekyll to Suit My Needs

This is going to be my last post on my Migration from WordPress to Jekyll (I promise :blush:). This week I am going to share with you some of the changes I’ve made, and plugins I’ve adapted to get everything running the way it was (ish) in WordPress. I’ve had to make a few changes to the site to suit the new system as well, but nothing major.

Tags

You may have noticed (but probably not really, that’s kind of the point) that there are no longer any tags listed at the bottom of each post. Tags are a standard part of WordPress that I embraced for no other reason than ‘they were there’. Their purpose was to allow navigation between posts of similar topics that were not necessarily in the same category. To be honest, I don’t write all that many posts, and I don’t have thousands of people rading my blog so I decided they were completely unnecessary and ditched them in the migration.

Categories

I have also made a few changes to the categories. This is partially due to the way Jekyll handles categories, and partially due to me wanting to rationlise it a bit. In Jekyll, posts cannot be linked to multiple categories in the same way as WordPress. If there are multiple categories listed, they become subcategories of each other. For this reason, I had to adjust some of them so that they worked properly. For example, if an Instagram picture post included George, I filed it in both the Photography category and the George category. In Jekyll, this results in the post being included in the Photography/George (or George/Photography depending on the order) category, not two separate ones.

Jekyll does not generate category pages for you, so I looked at a few options for achieving this. Firstly, I made use of a standard plugin for generating the pages. I then made a few modifications to the plugin to get a result I preferred, and finally I adopted part of the plugin for generating the category list displayed at the top of each post and ditched the rest in favour of coding my own category pages. The plugin I am now using looks a little bit like this:

Pages

The way pages are organised in Jekyll is a little too messy for my liking so I have adopted a simple plugin that will keep pages organised in the same way as posts. They sit in a folder called ‘_pages’ rather than in the root of the repository. This keeps the root folder tidier :smile:. The plugin was written by Ben Baker-Smith and is available from here

Draft Post Publishing

Also in Jekyll, drafts are kept separate in a ‘_drafts’ folder, but there is no real way to handle them when they are ready to publish other than to move the file to the ‘_posts’ folder and rename it prior to deploying the update. This is not a difficult task, but there is a better way. Rake is a build program that is used by a lot of web programmers to automate simple, but time consuming tasks. This seemed to me to be the perfect solution, but my distinct lack of skills in Ruby meant I had to start with Google. This led me to a script by Shane Burkhart that was almost exactly what I wanted. With a few minor tweaks I ended up with this:

This also led me to automating a load of different tasks to generally make my life easier. If you’re interested, you can view my full ‘Rakefile’ here (this isn’t used anymore so this is a link to the last version of the Rakefile usaed by my site).

Series

My final tweak for the site was to reintroduce Post Series like I had on WordPress. The idea of a series is that posts about the same topic (like this one) include a list of all the related posts at the beginning of the post so that anyone reading it can refer back if they are interested. This is again not a standard function of Jekyll, but with a bit of research I found a great plugin written by R.J. Lorimer that was just what I needed. (As usual) I made a few modifications and this is the result:

I combined this with a custom template for the series pages and now article series work better than they did before :smile:.

Conclusion

Over the last couple of weeks, and previously the last couple of months, I’ve documented the process I’ve gone through to migrate my blog from WordPress to Jekyll. Hopefully some of it has been interesting to some people, but really I’ve written it as a reference for myself.

I have very much enjoyed learning about Jekyll and how it works, as well as bits of a new programming language, but mostly I’ve enjoyed tinkering with something that already works fine. I feel that I am definitely a bit of a tinkerer, but there’s no harm in it really, is there? :wink:

comments powered by Disqus