At least for this blog. (Jump right to the Jekyll-part)
It’s amost 3 years ago since I moved this blog blog from textpattern to wordpress. The main reason was because there’s a ton of plugins to extend the blogging experience and also — I have to admit — because everybody used it. Wordpress’s ecosystem grew further and today we have companies like WPEngine that were build on top of it.
Wordpress is nice, so what’s the matter? Well, my server crashed a few times in the last year mostly because it couldn’t handle the load. As it is only running lighttpd and MySQL it is easy to pinpoint what the problem is. I’m currently running a growing number of Wordpress instances (plus some handmade code) on this server. You can install Wordpress in 5 minutes but I can’t migrate to a bigger machine in 5 minutes. “The Cloud is the solution”, one would say. Indeed, it is a solution but a rather expensive one [1][2] for this blog.
So instead of constantly switching to bigger machines or invest in the cloud, I want to reduce the load (who doesn’t want that?) and speedup the page generation. The $100-question is how? I’ve already tried some stuff:
First I had some problems with the cache-plugins for Wordpress but all of these tweaks kinda work as promised.
There has to be more. Long story short: This is my first try to replace one Wordpress installation with Jekyll. If it works out I consider replacing the other one as well.
Jekyll is a simple, blog aware, static site generator. It takes a template directory (representing the raw form of a website), runs it through Textile or Markdown and Liquid converters, and spits out a complete, static website suitable for serving with Apache or your favorite web server. This is also the engine behind GitHub Pages, which you can use to host your project’s page or blog right here from GitHub.
There’s probably nothing to add. The optimization consists of basically replacing all dynamic parts of a blog with client-side code (Disqus with JavaScript) and leave the rest static.
This was my todo list to do a clean migration from Wordpress to Jekyll which I want to explain in the next part.
This task is the easiest one. Simply fork one of the many git repositories on github (like the one from mojombo or jekyll-bootstrap):
With that you have a working (local) jekyll repository. To generate the site simply run
By default the result is stored in _site
.
You have two options. One is to install the Disqus plugin for Wordpress or to export your comments to a XML-file and upload it to Disqus. For either approaches, it took almost a day to import the 11(!) comments.
I tried both ways which are really straight forward but had the problem, that special characters were translated to their escaped hexadecimal representation which looked ugly.
Jekyll comes with a bunch of import-scripts to import posts/pages from Drupal, Textpattern and also Wordpress. I used the mysql-migrator for wordpress:
Take a look into the wordpress.rb
for more options. I used the additional parameters to also import categories and tags.
I’m using Sass and Compass since a few weeks and already love it. The two are quite easy to integrate into jekyll. Simply create config.rb
which should look like this and don’t forget to exclude the config and the sass
folder from jekyll.
It’s also nice to use foreman
for the compass compilation step. Create Procfile
with the following:
With that you can run foreman start
and it will start and watch both compilation tasks which is very nice for development on your local machine.
By default, Jekyll provides an atom.xml
feed in the root folder. Wordpress’s feed in contrast is usually in /feed/
.
For that, create a folder feed and move the atom.xml
to feed/index.xml
. You may have also to change the index-filenames in your webserver configuration to support index.xml
as well.
Wordpress provides index pages for tags and categories, for free. With Jekyll we have to add this feature. Jose Diaz-Gonzalez has written a few plugins to support these kind of standard weblog extensions.
generic_index.rb
is the one we’re looking for. Download it to your _plugins
directory and edit the config.yml
like that:
Now, for each index page (tag and categories) create a file _layout/(tag|category)_list.html
:
And _layout/(tag|category)_index.html
with something like that:
There are lots of Rakefiles out there, so my advice is to pick the best parts (e.g. from Octopress) und create your own. This could be the basis:
If you’ve followed this introduction to jekyll you probably have a good working installation by now. So remember what the goal was? Right, to decrease server load und to speedup the page generation. As it is too early to give results, I will do a follow up post in a few weeks or so.