hexo-github-blog-build-on-ubuntu-en
Based on a Zhihu article—the original is more detailed, but where they disagree, follow this post.
https://zhuanlan.zhihu.com/p/35668237
Install Node.js
sudo apt install nodejs
Ubuntu’s packaged Node was too old; upgrade to a current release.
https://askubuntu.com/questions/426750/how-can-i-update-my-nodejs-to-the-latest-version
Use n module from npm to upgrade node:
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
To upgrade to latest (not just current stable):
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 n
You may need to restart the terminal to see the new node version.
The following steps mostly follow the original article; omitted here.
Install Hexo
Official docs: https://hexo.io/index.html
npm install hexo-cli -g
hexo init blog
cd blog
npm install
hexo server
If something fails, try 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 an SSH key:
ssh-keygen -t rsa -C "shemol@163.com"
cat ~/.ssh/id_rsa.pub
Copy the output into GitHub → SSH keys, save.
Run ssh -T git@github.com; if it greets you by username, it worked.
Open _config.yml at the blog root and set deploy:
deploy:
type: git
repository: <https://github.com/SherlockShemol/SherlockShemol.github.io>
branch: master
Point repository at your own GitHub Pages repo.
Theme
See the original post.
npm install errors with Even: https://sobaigu.com/hexo-renderer-sass-error.html
Use:
npm uninstall hexo-renderer-sass
npm i --save hexo-renderer-sass-next
Follow the theme docs for the rest.
Hexo deploy and GitHub
GitHub now requires a token instead of a password for hexo deploy.
Settings → Developer settings → Personal access tokensand create a new token.- After
hexo -d, a prompt asks for credentials—use the token, not your account password.
Reference: https://blog.csdn.net/qq_21040559/article/details/122621179