Migrate Blog to Hexo

This post is a celebration for the migration from Octopress to Hexo

Octopress has done an excellent job on filling the gap between jekyll and full function repo based blog engine. But because of the tech stack it is based on. It isn’t really a awesome framework to use.

The first time I got pissed off by Octopress was by the end of 2012. Then I come up the idea to rewrite it in Node.js. But I wasn’t able to make it happen, because I was held by the new project assignment, and didn’t have too many spare time on the blog engine.

To save effort, I began to customize Octopress by rewriting some code in Octopress and Jekyll, which started the long march of Octopress customization.

I did a number of customization on Octopress, from erb template to Jekyll generators, from Rake script to TextMate bundles.

Before I switch to Sublime, I uses TextMate for quite long time. So I customized the Rake script and TextMate bundle, which enables me to invoke almost every rake command in TextMate with hotkey. I can even rename the blog post file name according to the title in front-matter without leaving TextMate. Besides the functionality, I also customized the templates and the widgets a lot to get better visual effects and reading experience.

I’ve benefited from these customization a lot. On the other hand, these deep customization blocks me from migrating to Hexo, a better alternative. Even I have found Hexo in the early 2013, and believe it is a better blog platform. But it is really costy for me to migrate the blogs away from the Octopress.

Luckily, after years development, a bunch of tools and libraries came up, which has minimized the gap between Octopress and Hexo.
After several days effort, finally retired the Octoress engine, and completed the journey of moving from Octopress to Hexo.

I decided to turn to Octopress

I have spent almost a week to fight against the code highlight system in jekyll, but finally failed.

At very beginning, I tried the “legendary” “github flavored markdown”, which supports use “```” to quote and highlight code. But soon, I failed.

Then I tried pygements, but sooner I found the perfectly local rendered code fails to be rendered on github pages, the reason seems caused because the github use a older version of the pygements.

Since I cannot fully control pygements as I expected, so I turned to a javascript version code highlighter, SyntaxHighliter.

Soon, I found SyntaxHighlighter cannot cooperate with jekyll’s markdown compiler well, so I tried several approaches to make them work together. I change part of the SyntaxHighlighter’s implementation and added several new includes liquid template based on Jekyll Bootstrap.
But it still cannot work perfect.

The problem is that jekyll markdown parser cannot distinguish the html snippet perfect, it usually try to parse the code as html.
Then I tried to quote my code with CData tag, but I found the generated html are not consistent. Some of which the “<” and “>” are escaped with “&gt;” and “&lt;”. And some other are not escaped but quoted with “”. It is really hard to deal with so many cases in javascript.

So I gave up. I gave up to use the github to render my pages. So I guess Octopress must be a good option for me.
Since Octopress is based on jekyll but with a lot of new goodies. These new liquid markups are powerful and can fulfill my requirements.