I Switched My Blog From Blogofile to Pelican

Tue 06 August 2013 Category: Uncategorized

This blog is a static website, which makes it fast, simple and secure. It was generated by Blogofile but I switched to Pelican.

Blogofile has seen almost no updates over the years and I consider the project dead. Realising that blogofile is dead, I decided to look around for different open source static blog generators.

There are many other static blog generators than pelican. But Pelican is well-documented, is based on Python, is very actively maintained (good track record) and supports all features that I wanted. Some of those features are Atom/RSS, Disqus and Google analytics support.

My blog posts are written using Markdown. This makes it very easy to migrate away from Blogofile to Pelican, as Pelican also supports Markdown. Blogofile uses a different header format not recognised by Pelican, so you have to search and replace some key words in all your files before Pelican can actually generate your new website.

I wrote this horrible bash shell for-loop to process all my blog posts:

    :::bash
    for x in *.md
    do
        TITLE=`grep -i "title:" "$x"`
        TITLEFIXED=`echo $TITLE | sed s/\"//g`
        DATE=`grep -i "date:" "$x"`
        DATEFIXED=`echo $DATE | sed "s/\//-/g" | cut -d ":" -f 1,2,3`
        CATEGORY=`grep -i "categories:" "$x"`
        CATEGORYFIXED=`echo $CATEGORY | sed s/\"//g | sed s/categories/category/g | cut -d "," -f 1 | /usr/local/bin/sed -e "s/\b\(.\)/\u\1/g"`
        echo "$TITLEFIXED" > tmp.txt
        echo "$CATEGORYFIXED" >> tmp.txt
        echo "$DATEFIXED" >> tmp.txt
        grep -v "title:" "$x" | grep -v -e '---' | grep -v -i "date:" | grep -v -i "categories:" >> tmp.txt
        mv tmp.txt "$x"
    done

Notice how Build-in syntax highlighting of Pelican applies nice colors to this horrible code. Regarding this horrible code: I had to use GNU sed as the Mac OS X sed did not support the regular expression I used.

To enable comments for my blog posts I always used Disqus with Blogofile. Pelican generates web pages in a different way compared to blogofile, so all old pages need to be redirected to the new location. I used the redirect functionality of Lighttpd to redirect all existing pages to the new location.

The cool thing is that Disqus has a tool called "Redirect Crawler". If you have configured 301 "permanent redirects" for all pages and run this tool, Disqus will automatically update all existing links to the new locations, so your comments are migrated to the new web pages.

Furthermore, I've implemented a Pelican plugin called titlecase which capitalizes the first letter of words in the title of your article. It's just that I think it looks better.

I think I'm really happy with Pelican.

Comments