From Jekyll to Pelican

Written by
Date: 2013-01-09 11:14:13 00:00

I am not switching to Pelican, at least not yet, Jekyll does everything I need (I wish it could support translations). But on the other hand, I love learning so I was experimenting with Pelican.

To move from one to the other is really easy, just install Pelican in your computer, and move _posts files to contents. The only problem you will face is that Pelican does not understand YAML front matter.

You need to change this:

title: My first post
date: 2012-12-21 00:00:00 00:00

To this:

title: My first post
date: 2012-12-21 00:00

With only few posts, that is easy, if you have a lot of posts, you will need something automatic, I have found that sed is great at this. And these two commands helped me moving some posts for my experiments with Pelican.

sed '1d;4d' *.md

This command will remove lines 1 and 4, you need to modify the numbers you want to remove from your YAML front matter.

sed -e "2s/..........$//" *.md

That line will open every document in current folder with .md extension, and echo its contents, but it will delete the number of dots starting at the end of the line from line number 2, you will have to adjust it to your needs, to have the right Pelican date format, you may need to change the number 2 in the command to hit the right line.

I am using 2, because I have applied this command after the one that removes the dashed lines.

Those commands as they are, will not change anything in the files, the output will go to the screen. Review the results and then apply them in this way.

mkdir _posts/tmp
sed '1d;4d' *.md > tmp/
mv tmp/* .

That is it, apply the same way for the other command and you are done.

You have a backup of all your posts in other safe place right?