Switching from Wordpress to Nikola

For a while now, I haven't really written anything interesting for my blog. It does contain enough stuff to still be interesting and I guess it does contain some stuff that's simply dear to me. Hard to let go of, at least. But that's not really a good reason to have a full blown Wordpress running. Wordpress has a lot of issues, mostly related to security. Don't get me wrong, if you write a lot and often, Wordpress is a nice platform. But for me, it's kind of overkill. I'd be happy with a static site that I can easily expand.

Enter Nikola, a Python-based script that can generate static pages from simple blog posts. Which is a lot more work than you would imagine, I'm sure. One of the nice things is that it can import a Wordpress XML export, which allowed me to keep all the posts I've been writing on and off in the last 10 years. Quite neat.

It works pretty intuitive, you write a blog post in reStructuredText (rst) (or MarkDown, if that's your thing or a lot of other markup languages) in your favourite editor. Then you tell nikola to build your site, after which the system checks what needs to be done and actually does it. It saves the output in a directory called /output, which you can rsync to the documentroot where you actually want to host your site. Quite simple, I'd say.

For the old Wordpress links, nikola creates dummy pages. I didn't really like that solution, so I wrote some rewrite rules in the Apache config for this:

RewriteRule ^/feed/atom/ /rss.xml [R=301]
RewriteRule ^/([1-2][0-9][0-9][0-9]/[0-1][0-9]/[0-3][0-9]/.*)/.*$ /posts/$1.html [R=301]
RewriteRule ^/(tweets/[0-9]+)/.*$ /stories/$1.html [R=301]

I didn't test this very elaborately, but it seems to work for me. Maybe this will help someone else as well.

There was one thing that required me to do some digging, though. Apparantly, for some unknown reason, my Wordpress XML export contained a few ^P characters. No idea why they were there, but I had to go in and remove them manually, otherwise nikola would not import the data.

I also lost all of my old comments. Since nikola creates static sites only, it cannot work with comments by itself. But it does support systems like Disqus, which I decided to use myself as well. I didn't get a whole lot of comments on my site, so I don't think it's very important. Depending on your setup, this might be a problem for you, though.

A lot of info should be gotten from small side scripts, I guess, or Javascript stuff. That needs to be built, but I didn't think it to be very important. I'm also not sure if you can work with multiple users on a nikola site and have it display the correct owner of a text. Both things are not very important for me, though, although I'm considering switching our company blog to this as well, which would require the multi user stuff a bit.

All in all, I'm pretty happy with this system. I can see how this would be interesting for bigger parties as well, if someone would create a dynamic backend for actually creating the posts as well. It would allow you to completely decouple the backend from the frontend. Although I understand that corporate bloggers obviously require some more bloat on their site, I don't think it would be impossible to recreate that in either small javascript code or using SSI or ESI if you have a cache in front of it. It would probable lead to cleaner code as well, not to mention far easier to cache websites and thus responses.

Very interesting stuff, will be looking into this further, I think.


Comments powered by Disqus