Once everything in my server has been backup and had this running along for a bit with nothing going amiss, then I think I’d shutdown my paying server, and hopefully save some money (~100€ yearly).
Yeah, I know that I could have just started deploying my previous Pelican blog into Github. The main reason for a change is that Pelican required me a bit of fiddling and hacking around; which, ironically, is actually the reason I chose it in first instance. But this time, I want a little more features, for a little less effort. And if I end up forcing myself to dig into another system, I don’t want it to be in Python this time. Do not be mislead, I love Python; I just want to pop out of my comfort zone and see what happens.
The migration part
I had to convert about 3 years of writing (34 posts) stored as many text files, scattered within a 3 level hierarchy partitioned by year and month:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Each file having a header:
1 2 3 4 5
This setup is pretty close to the one that Jekyll uses, in which:
- Post file names must start with the date.
- The header have the same fields, but must be valid yaml at the start of the file, using
---lines as separator.
So it was just a matter of finding, copying and properly renaming all the posts from the Pelican source directory.
1 2 3 4 5 6 7 8 9
The previous listing was prettyfied for displaying, the actual command was more like:
for post in $(find -name *.md); do date=$(grep -i "date: " $post | sed -e "s/[dD]ate: \([0-9-]\+\).*/\1/g"); if [[ ! -z $date ]]; then mv $post $date-$(basename $post); fi done
After that I had to manually add the
--- separator to each post header.
I couldn’t find a simple way of running a multiline
sed replacement for all of them, so I opened all files in with
vim *.markdown, recorded a macro, and runned
it for all the 30 buffers. It took me about a minute or two.
Then copy the
img directory, which contained the assets, maintaining the same relative path for
all post images.
Octopress is nothing but very convenient for slackers. You clone/fork their repo in github, and you already have a nice Jekyll setup. They have very detailed tutorials on their site, so the part of installing ruby, the gem and all that, I’m not repeating it here.
Once you’ve filled the
._config.yml file with your own data and have all posts within
rake generatewill create static html with your blog.
rake previewwill serve it on
localhost:4000for you to revise.
rake deploywill commit the generated html to the github repository you specified in the config.
¿My github repository? Yeah, create a
username.github.io named public repository along with your
own and put your domain within a
CNAME file under
echo "blog.ragingbit.com" >>
source/CNAME if you’re using your own domain.
The html output will be commited to the
master branch, the actual blog markdown code, will go to
source branch. So you
rake deploy for publishing, and
git push origin source for actually versioning your
So, here we are, new hosting, new blog.