I changed my blog from Wordpress to Jekyll!

Why i switched to Jekyll

I was thinking about switching from Wordpress to something else for quite a while, but I didn’t find anything I really liked.

First I thought about switching my blog to a self made Laravel site, but it’s kind of reinventing the wheel. It’s a lot of work and is still open to bugs and exploits and therefore has to be updated really often - which I was not willing to do and also didn’t had the time for to do. Also I still would have PHP Code which to be totally honest I don’t really like because it is really slow in comparison to Node.js or Go code.

My second thought was to implement my blog in Go. Yay! The response time would be amazing and I sure would learn a lot - given I only played around with Go so far. But then again - a lot of overhead, fast out-of-date and time-consuming to maintain.

At first I was against static site generation.

I search a while and read a little bit more about static site generation and the more I thought about it the more it became clear to me: “This is the way to go.”

Static site generation was the key to the cons I had previously had against other solution. No security risks, because it is “only” HTML and no code is compiled on the server at runtime. No overhead - there are a lot of great static site generators out here and it would be - once set up - really fast to write articles and publish them.

Okay, so where to start?
There is Pelican, Pico, Nikola and of course Jekyll.

So I looked at them all with the following requirements:

  • easy to use
  • can import my post from Wordpress (would turn out as a ‘biggy’)
  • support Markdown
  • actively maintained
  • easy way to preview my work before uploading it to any server

Nikola

I started with Nikola because it seemed like the perfect fit to me. It met all my requirements and also was very easy to install on ArchLinux (yaourt -S python-nikola-git). So I headed right into it made a new git repo and nikola init to start a new Nikola instance. Okay now let’s import my Wordpress posts.
I made exported my posts from within Wordpress thought a XML file and executed Nikolas built-in import method nikola import_wordpress posts.xml. Wow, that was easy. Nope. Error. Damn it! DuckDuckGo to the rescue! Okay installed Nikola from source on Github. Still that Error. After a few hours of fumbling around I admitted defeat and moved on the the next generator on my list.

Pelican

Aswell as Nikola, Pelican checked off everything on my list so i also installed it. This time through pip. Just for funsies.

pip install pelican markdown
pelican-quickstart

Okay so now let’s import it.

pelican-import --wpfile --dir-page -o content -m markdown posts.xml

Cool, so far so good let’s look at my files.

python -m SimpleHTTPServer

Doesn’t work. Mhmmm… let’s try Python2.

python2 -m SimpleHTTPServer

Eureka! Long story short I really didn’t like the way theming works in Pelican. Although I thought I could live with that, there where still some alternatives on my list and I thought: “Better make sure you like it, because you’ll be using it for quite a while!”

Pico

Okay so I started on Picos website. Oh my.. PHP? Why? Oh boy, now I have to set up a complete web developing environment for a “simple” static site generator? Nah!
So I searched for lightweight Web-Servers for in-place use.
I discovered node-sng and thanks to Arch it was also easy to install.

But at this point I thought I just drop Pico because it is not practical for me and thus I wouldn’t use it for long.

Jekyll

Let’s try the clear mainstream option. Nice checks off everything on my list.

gem update
gem install jekyll

Nice! So let’s import everything. Awesome Doc is awesome!

ruby -rubygems -e 'require "jekyll-import";
    JekyllImport::Importers::WordpressDotCom.run({
      "source" => "wordpress.xml",
      "no_fetch_images" => false,
      "assets_folder" => "assets"
    })'

Mhm.. now my posts are still in HTML - I want them in .md format. Okay Bash-Script to the rescue! (you need pandoc to use this script)

#!/bin/bash
FILES=/home/nh/Desktop/posts/*
MDFOLDER=/home/nh/Desktop/mdfiles/
for f in $FILES
do
    completename="${f##*/}"          # complete file name with .ext
    filename="${completename%.*}"    # name without .ext
    mdname="$filename.md"            # lets add .md extension

    pathToMd="$MDFOLDER$mdname"      # define the output path

    # Let's rock!
    echo "Processing $mdname"
    pandoc -s "$f" -o "$pathToMd"
done

Awesome! Let’s compile them and look at what I’ve got so far.

jekyll serve -w

Oh it looks kind of messy. The file header it not right. Okay I will go through my posts I also need to change some image urls and stuff.
Nice auto-compile function! While we’re at it let’s also install a nice theme.

Here are some useful code-blocks:

Conclusion

Although it was quite some time editing 60+ posts I really like the result and you may like it too! I’m really glad I took the journey to discover Jekyll.

This very article is my first one completely written in Jekyll on my beloved SublimeText-Editor with some Plugins. (Jekyll, Markdown Preview and Markdown‚ÄčEditing)

I hope I gave you some insights in my journey and maybe you can save yourself some trouble and fist try Jekyll before you end up digging through the entire internet to find a static site generator you like.

Good luck! ;)