Testing my new blogging platform

After trying to get wordpress to perform properly on my webserver hosting 7 domains, I decided to try something completely different.

I decided that I would try a static blog generator for a number of reasons:

  • Security: Since only static files is served, there is no more vulnerabilities in wordpress or its plugins.
  • Simplicity: I can write a blogpost in my favorite editor, upload via SSH, and presto, it's up on my site.
  • Learning: I love learning new stuff. I have been using wordpress for a couple of years now, writing small plugins and such, but now it's time to move on and learn something else.

I didn't really have any specific requirements to the blogging platform, other than it should be written in python and be fairly stable (read: usable). So, I read a couple of blogposts about various static blog generators, and decided on Pelican. It seems nice, fairly easy to use and I'm sure I will learn a bit writing plugins for it (I already have a couple of ideas).

To import my old blog posts, I first exported them via the wordpress administration interface (Tools->Export). Then, you need to install a couple of programs and libraries and then you import it - simple:

sudo apt-get install pip python-lxml pandoc
sudo pip install beautifulsoup4
pelican-import --wpfile ./yoursite.wordpress.2013-08-08.xml -o ./content/ -m markdown

This will import the content of yoursite.wordpress.2013-08-08.xml into ./content/, saving every blogpost in the markdown syntax.

Now, I ran into a few problems. First of, since my username was "admin" on my wordpress blog, the author of every single post on my pelican powered blog is admin - not cool, but easily fixed:

sed -ie 's,Author: admin,Author: Jannich Brendle,' ./content/*.md

Second, with pelican, every blogpost can only be in one category, but it can have multiple tags. I haven't really decided if this is a good thing yet, but I guess it makes sense if you write posts that are easily classified. So, I had to fix that too. To find all the blogposts with more than one category defined, use this command:

egrep 'Category:.+,' content/*.md

Now, I only needed to configure pelican, so the articles was reachable on http://mysite.com/article-name-here instead of http://mysite.com/article-name-here.html - luckily, that too was fairly easy to solve. In your pelicanconf.py add this line:


and in lighttpds config file /etc/lighttpd/lighttpd.conf, add these lines:

server.modules += ("mod_rewrite")
    # Rewrite everything with a file extension to point to itself (ie. don't change it)
    "^/(.*)\.(.*)$" => "$0",
    # rewrite anything else to point to itself plus the .html extension.
    "^/(.+)$" => "$1.html"

Restart lighttpd, regenerate the html for the blog content and it should work. :-)

Another thing that I needed to change was, that the URLs for various titles with danish letters were not the same before and after the conversion, due to Wordpress having utf8 percent-encoded characters in the slugs.. Easy to fix though:

cd content
sed -ie 's,%c3%b8,ø,g' *.md
sed -ie 's,%c3%a6,æ,g' *.md

So, now that those small issues are solved, I'm pretty much set, I think. I'll write another post on how I'm liking the new blogging platform. :-)

Written by Jannich Brendle ons 07 august 2013 In Blogging

tags: bloggingpythonchanges

Related posts