After a few years of using Google Blogger, I decided to switch to a different on-line publishing platform. It is not that there is anything wrong with Blogger, I am just looking for a change; I also think that there is a chance that Blogger will be subsumed by Google+ someday, and that is not the platform I am looking for. Twitter is presently my social network of choice, but I periodically want a way to publish things which are longer than 140 characters. Prior to using Blogger I had my own Wordpress server, but I concluded that keeping a personal server up to date with all the latest security patches was not an effective use of my time, so I am not interested in going back to that arrangement. Besides, today there are so many cloud based solutions available that I see even fewer reason to invest in maintaining a private server. Tumblr has become a very popular platform, but I’m not sure what Yahoo’s acquisition of it will mean in the long run. I could switch to a hosted Wordpress service, but that seems to be more powerful than what I need. I mostly publish text with code examples and a few images, so I could use Panic Coda to publish a static website, but that would mean that for each post I would have to modify at least two pages: the new post and the index. I just need a simple text blogging platform, perhaps one that will accept Markdown and make it super easy to write a post.

After searching the web I stumbled onto GitHub Pages. I use GitHub, so I’m not sure why I didn’t think about this before; I guess I just associated it with code projects. GitHub Pages would be a good place to publish static content from Coda, but I would still like to have some sort of index page like a traditional blog. Fortunately, GitHub Pages includes Jekyll support. Jekyll is a tool which can create static websites from templates and Markdown based text files. Once my template is created using HTML, CSS, and Liquid, I can simply add new Markdown files to my stollcri.github.io repository and GitHub will use Jekyll to create the post and update the index page. This is sweet.

The only thing left was to find a way to import my Blogger data. With a quick search I found a Ruby Gist to convert a Blogger export for use with Jekyll. The script worked flawlessly, it brought the Blogger contents over as HTML so none of the formatting was missing. I did want to make some changes to the meta data it had generated. It made all the Blogger tags into Jekyl Categories and I wanted them to just be tags, so I opened up Sublime Text and did a replace in files. I replaced “categories” in the front-matter with “tags”. While I was at it I added a “Blogger” tag so I would know which ones were imported. I probably could have just modified the import script, but this was just as fast to do. Finally, I did not want any existing links to my site breaking when I move my domain name, so I wrote a small script to set the permalink variable for each page to match what it was in Blogger. The script is below, highlighted thanks to the Pygments support.

#!/bin/sh

if [ ! -e "$1" ]; then
	echo "Usage:\n $0 file_names-one_per_line.txt"
	exit
fi

# read bug IDs into an array
declare -a filenames=(`cat $1`)

((i=0))
while [[ ${filenames[i]} ]]; do
	filename="${filenames[i]}"
	fileyear=`echo "$filename" | awk -F- '{print $1}'`
	filemonth=`echo "$filename" | awk -F- '{print $2}'`
	filetitle=`echo "${filename:11}"`

	filecontents=`cat "$filename"`
	echo "${filecontents/permalink:/permalink: /$fileyear/$filemonth/$filetitle}" > $filename

	echo "OK: /$fileyear/$filemonth/$filetitle"
	
	((i=i+1))
done

The only thing left to do now is to find all my images and move them over, and redirect my domain name to my new GitHub Pages site. This feels like a more developer-centric solution to the problem; I am really happy that I can simply publish Markdown files as blog posts. Maybe it will make me post more than once or twice a month.

Tags: Jekyll GitHub Pages Markdown

Published: 2013-12-22