Based on a Zhihu article. The reference is more detailed; where this differs, follow this post.
https://zhuanlan.zhihu.com/p/35668237
Install Node.js
sudo apt install nodejsHit a version problem right away. Ubuntu's Node is too old; Node.js should be upgraded to the latest.
https://askubuntu.com/questions/426750/how-can-i-update-my-nodejs-to-the-latest-version
Use n module from npm in order to upgrade node
sudo npm cache clean -f
sudo npm install -g n
sudo n stableTo upgrade to latest version (and not 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 version of Node that was installed
sudo npm uninstall -g nYou may need to restart your terminal to see the updated node version.
Some of the later steps can follow the original article; I won't repeat them.
Install Hexo
Follow the official method.
npm install hexo-cli -g
hexo init blog
cd blog
npm install
hexo serverIf a step fails you can try adding sudo?
Connect GitHub and the local machine
npm install hexo-deployer-git --savegit config --global user.name "SherlockShemol"
git config --global user.email "shemol@163.com"Generate an SSH key
ssh-keygen -t rsa -C "shemol@163.com"cat ~/.ssh/id_rsa.pubCopy the output into the box, paste it under SSH keys, confirm and save.
Run ssh -T git@github.com. If your username appears, it worked.
Open _config.yml in the blog root. That's the blog config; you can change various blog-related settings there.
Change the last deploy block:
deploy:
type: git
repository: <https://github.com/SherlockShemol/SherlockShemol.github.io>
branch: masterSet repository to your own GitHub project URL.
Change the theme
See the original blog.
Mine is the Even theme, GitHub
npm install errors under Even
https://sobaigu.com/hexo-renderer-sass-error.html
Use
npm uninstall hexo-renderer-sass
npm i --save hexo-renderer-sass-nextThe rest is in the docs.
Hexo deploy issues
GitHub's new rule: pushing from Hexo now requires a token.
Fix:
- Go to
Settings->Developer settings->Personal access tokens->Personal access tokensand generate a new token - After
hexo -da dialog asks for account and password. The password here is the token, not your GitHub password
Reference: https://blog.csdn.net/qq_21040559/article/details/122621179