hexo

This post is somewhat talking about itself as I just happened to move my previous blog to a markdown framework powered by Node.js called Hexo.

I was aiming for something:

  • fast
  • lightweight
  • flexible
  • w/out database
  • w/ markdown support

Among all of those plain text frameworks and even though Jekyll was an option, I wanted to try something new and solely focused on post writing.
That’s why I decided to give Hexo a go.

For a first impression it’s terribly fast (Node.js got the props), for sure the community around isn’t that big but the documentation is detailed enough to make your own way through your custom blog system.

This is how you should start a hexo project:

1
2
3
4
5
$ npm install hexo-cli -g
$ hexo init blog
$ cd blog
$ npm install
$ hexo server


So I was totally satisfied with that and ported my previous blog layout to it.
After defining your own categories or tags in the post YAML frontmatter, it’s pretty straightforward to get a list of posts ordered by categories:

1
<%- list_categories([options]) %>

One annoying feature (bug?) I stumbled across was when it comes to define multiple categories for the same post. By default, they are all wrapped up inside sub-categories as a parent siblings. You don’t want to end up with duplicate sub-sub-categories, right ?

I managed to find a workaround in order to get rid of this unwanted depth, found out that the culprit was hiding under “hexo/lib/plugins/helper/list.js” inside the node_modules folder.

After checking the categories depth, each child get its own path affected automatically like so:

1
2
3
4
arr.push('<a class="' + className + '-link" href="' + self.url_for(cat.path) + '">' +
options.transform(cat.name) +
(showCount ? '<span class="' + className + '-count">' + cat.length + '</span>' : '') +
'</a>');

All happens in this very bit, a quick hack is to replace the category path by using categories name directly instead of the sub paths you would normally get.

1
self.url_for("categories/"+cat.name+"/")

And now you have it, a whole new blog to fill up with as much as top level categories as you want.
There might be some little fixes to provide here and there but I’m pretty satisfied with this current setup and ready to write the next adventures.