Setting up Hexo+Github blog on Ubuntu (Zorin)

Refer to the Zhihu article for more detailed information. However, please consider my article as the main reference in case of any discrepancies.

Install Node.js#

sudo apt install nodejs

I encountered a version issue right from the beginning. The version on Ubuntu is too old, so Node.js should be upgraded to the latest version.
Use the n module from npm to upgrade node.

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

To upgrade to the latest version (and not the current stable version), you can use

sudo n latest
  • Fix PATH:
sudo apt-get install --reinstall nodejs-legacy     # fix /usr/bin/node
  • To undo:
sudo n rm 6.0.0     # replace number with the version of Node that was installed
sudo npm uninstall -g n

You may need to restart your terminal to see the updated node version.

The following steps can refer to the original article without further elaboration.

Install Hexo#

Follow the official website's instructions

npm install hexo-cli -g
hexo init blog
cd blog
npm install
hexo server

If there are any errors during the process, you can try adding sudo.

Connect Github and Local#

npm install hexo-deployer-git --save
git config --global "SherlockShemol"
git config --global ""

Generate SSH key

ssh-keygen -t rsa -C ""
cat ~/.ssh/

Copy the output and paste it in the box. Click OK to save it in SSH keys.

Enter ssh -T, if your username appears, then it is successful.

Open the _config.yml file in the root directory of the blog. This is the configuration file for the blog, where you can modify various information related to the blog.

Modify the configuration on the last line:

  type: git
  branch: master

Change the repository to your own GitHub project address.

Modify Theme#

Refer to the original blog
Mine is the Even theme, Github address
There is an error when running npm install under the Even theme

npm uninstall hexo-renderer-sass  
npm i --save hexo-renderer-sass-next

The rest can be found in the documentation.

Hexo Deployment Issue#

According to the new rules on GitHub, you can only use a token to submit code from Hexo.


  1. Go to Settings->Developer settings->Personal access tokens->Personal access tokens to generate a new token.

  2. After executing hexo -d, a dialog box will prompt you to enter your account password. Note that you need to enter your token here, not your password.


Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.