Other Posts

Why Hugo Why Not Hexo

As you probably remember that I just about switched from jekyll to hexo 2 months ago, now I’m again switching from hexo to hugo. Am I crazy? Yep. You want to know why? Let me tell you.

Why hexo was chosen?

Let’s start from the reasons why I ditched jekyll without any regrets:

  1. Hexo has a good name
  • Hexo is powered by Node.js
  • Hexo is easy to deploy
  • Hexo supports theme change
  • Hexo is pretty fast

Honestly hexo is quite good and I’m pretty happy living with it. I have a “clever” repository setup of hexo in GitHub:

  • Branch hexo: to keep source code, posts and theme
  • Branch master: to store all generated static files

I found a useful deploy plugin, which allows me to write posts and backup them in hexo branch, to publish final static files easily to master branch. I’ve to say I got nothing to complain. Hexo works as expected, all 👌

Why I choose hugo then?

You know I’m a guy who crave clean & fast thingy and I never settle down. I cannot control myself not touching cool thing. Hugo, another popular static web generator engine, is mentioned a lot as “an alternative” of jekyll and recommended by some cool guys. When I’m motivated, I won’t give up the chance to try hugo, would I?

1. Even better on theme changing

Hexo supports theme change flexibly:

  1. Download a new theme
  2. Update _config.yaml to use it
  3. Run server

Hugo is even better:

  1. Download a new theme
  2. Run server with theme name as a parameter, done!

2. Zero dependency

Hugo is built using Go, free, open source. If I only want to use hugo without building from source, I could just download executable release binary. Literally it has zero dependency, one binary that’s all, so clean. On the other hand, hexo requests much more. First npm, then install around 10 dependencies during initializing. Now I’ve only basic functionalities of hexo. If I want to generate emoji, 👌 add a plugin; if I want deploy code automatically, 👌 add another plugin; if I want backup code automatically, 👌 add another plugin

3. Lightweight file structure

Not to say if node_modules is a design flaw of npm, the fact is that node_modules is bloated heavily, interesting post here and interesting discussion here. Hexo is powered by Node.js and naturally bloated by it. That’s why node_modules is that place where I really don’t want to look deep inside. To have a better understanding, I roughly checked the size of folders including the same theme and the result is kind as expected:

Hexo w/ node_modules: 18M
Hexo w/o node_modules: 69M
Hugo: 29M

4. Little surprises

After I know more about hugo, I get more little surprises:

  • LiveReload: it instantly reloads browser after any changes. Based on hugo’s build speed, it’s super continent for developing theme and checking post’s looking, easy and fun. I like its speedy live reload. ⚡
  • Aliases: I call it page redirect. Once I put alias URL in a post and then visiting this alias URL from browser, hugo will redirect alias URL to post URL. It easily solves the problem of URL changes caused by migration from other frameworks.

Summary

To sum up, hugo is definitely my new favorite. But hexo is actually good enough to suit my needs. It seems hard to pick one, so my suggestion is following. Imagine you would like to build your own static web pages:

  • You start from fresh new, I will recommend you give hugo a try first.
  • You already use hexo, and you are a fan of JavaScript, then hexo is the one to stick with.
  • You already use hexo, and your plan is to spend time on writing, then hexo is good enough.
  • You already use hexo, and you want to learn new thing, and you’ve 1-2 days free time, then hugo would be a good choice for you.
  • You already use hugo, then keep using hugo and don’t look around 😉