The Library Basement
Reading under ground

Pelican Implementation

In this post I'll share some of the implementation details for converting this blog from WordPress to Pelican. The process was not difficult, but it did require a bit of figuring to get everything right. Luckily Pelican has good documentation.

File import

Pelican comes with an importer for WordPress XML, so that made things nice and easy. I simply exported from my site and re-imported it into Pelican, converting to Markdown. One thing about the Markdown conversion that did not go well was that the "alt" text of images did not come through correctly. I think this was due to an alternate syntax for links being used by the converter.

Post URL format

I used the /year/month/day/slug format for my WordPress posts (e.g. ""). By default Pelican saves the output HTML in a flat structure. If you care about preserving links, this won't do. I used the settings ARTICLE_URL and ARTICLE_URL_SAVEAS to get Pelican to match the output. There are two ways you can go with the SAVEAS setting. Either you can put an index.html file inside the folder path (e.g. /2014/03/21/pelican-implementation/index.html), or you can use some sort of rewrite rule in your web server to point the clean path to the HTML in question. I went with the fool-proof index file method. Here are my versions of these settings:

ARTICLE_URL = '{date:%Y}/{date:%m}/{date:%d}/{slug}/'
ARTICLE_SAVE_AS = '{date:%Y}/{date:%m}/{date:%d}/{slug}/index.html'


Wordpress sticks its uploads in the wp-content directory. You'll probably want to put those contents inside your "images" folder in your Pelican project, and then edit your imported posts to re-point the paths. I used the following to edit the files in place:

for f in *.md; do sed -i "s/wp-content\/uploads/images/g" $f; done



You can use git or another vcs to keep track both of your inputs and outputs. I'd use the following setting in your file to let Pelican know not to mess with git in your output directory:


The End

The majority of the time I spent on this project was on creating my own custom theme. Theming templates was easy with jinja. I am just bad at CSS. I tried to avoid JavaScript for the function of the page. It is only used in my analytics tracking code (Piwik). I also link to Google for some web fonts. But browsers will fall back if the visitor chooses to block remote @fontface calls.

That's it. Let me know if you have any questions.

Category: meta Tags: Pelican