banner
Shemol

Shemol

我好想伸出手,拥抱这个世界
pleroma
x
telegram
github

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.

https://zhuanlan.zhihu.com/p/35668237

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.
https://askubuntu.com/questions/426750/how-can-i-update-my-nodejs-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
https://hexo.io/index.html

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 user.name "SherlockShemol"
git config --global user.email "shemol@163.com"

Generate SSH key

ssh-keygen -t rsa -C "shemol@163.com"
cat ~/.ssh/id_rsa.pub

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

Enter ssh -T git@github.com, 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:

deploy:
  type: git
  repository: https://github.com/SherlockShemol/SherlockShemol.github.io
  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
https://sobaigu.com/hexo-renderer-sass-error.html
Use

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.

Solution:

  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.

Reference: https://blog.csdn.net/qq_21040559/article/details/122621179

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