Spend a whole night working on updating Hexo. It is much more complicated than I expected. For anyone’s convenience, I record some key points when migrate from Hexo 2.x to 3.0 besides the official documentation.
First things first: uninstall Hexo
Yes. Though the official wiki says that we can directly migrate from 2.x to 3.0, this doesn’t work (to me). Besides, instead of wasting time figuring out what’s wrong when updating, re-installating and configurating Hexo 3.0 seems acceptable to me. You can try to update directly but I didn’t do that successfully.
Before your uninstallation, backup your posts and any other custom setting files (eg. _config.yml
, your own theme file, etc).
To uninstall Hexo, use the node package manager(npm):
1 | npm uninstall hexo |
Now, install Hexo 3.0
Run
1 | $ sudo npm install -g hexo-cli |
Hexo wiki doesn’t mention the administration permission, but in my experience we have to add sudo
here.
Then we need to setup hexo folder in your desired place(folder).
1 | $ hexo init <folder> |
Still, try sudo
when you fail to run any command.
For your future convenience, we install all necessary services here:
1 | npm install hexo-generator-index --save |
and any plugins you probably need:
1 | npm install hexo-renderer-marked@0.2 --save |
All in sudo mode (or you can directly do all of these in sudo -i
mode).
Now, we finished installation.
Next, configuration
As before, most of the configurations are the same (in _config.yml
), but some tricky changes are:
deploy to github
Instead of set it asgithub
, set it togit
. Otherwise you will be fail when deploy to github.
In case you didn’t know how to deploy, go to this page and follow the instruction.content in each page
You will probably find that in archive or category, lots of posts are lost. This is because all pages show the number of posts as theper_page: 10
. (see this issue(chinese) in github) If you want to modify each page’s content, try add the following in_config.yml
:1
2
3
4
5
6
7
8
9
10archive_generator:
yearly: true
monthly: true
per_page: 0
category_generator:
per_page: 0
tag_generator:
per_page: 0About the theme, I prefer to add any feature or change anything by modifying the default theme(landscape) since it is a perfect suit for current Hexo version. If you use any third party theme you will probably find that it costs you long time generating all your posts when you have plenty of (200+) them.
According to the issues appear on github, there are many other problems in version 3.0. The killed problem is that some of the expressions (eg "-"
) can’t appear appropriately. Since Octopress also released its 3.0 early this year, I am wondering should I try to use Octopress. But the news is actually not that exciting on its website. So, question mark here.
Comments