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.
Very interesting stuff, will be looking into this further, I think.