Hexo Blog Develop Notes
Hexo Blog Develop Notes
Prerequisites: nvm for npm & node
Hexo also need git, but just one command:
1 | sudo apt install git |
Why nvm?
Until now, my ubuntu machine are using node version 18.20.2
and npm version 10.5.2
.
Hexo sometimes need a higher version number of both npm and node, then you may need nvm.
nvm is a version manager for Node.js, it allows you to quickly install and use different versions of node via the command line.
Git Repo for nvm is here.
Install nvm
Recommanded install nvm using bash:
1 | curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash |
Then add nvm to the Path
:
1 | # ~/.bashrc or some kind of ~/.zshrc |
Check nvm version by:
1 | nvm --version |
Usage
check node version
To check the node version:
1 | nvm ls |
install specific version of node
To install a specific version of node:
1 | nvm install ${NODE_VERSION_NUMBER} |
If you just wan to install the latest release of node, just
nvm install node
When you install a new node version, it would change your node version into it.
If you want to change node into a specific version of node:
1 | nvm use ${NODE_VERSION_NUMBER} |
Remove a specific version of node:
1 | nvm uninstall ${NODE_VERSION_NUMBER} |
install npm for each node
nvm also alow you install different version of npm for each node:
1 | nvm install-npm ${NPM_VERSION_NUMBER} ${NODE_VERSION_NUMBER} |
First Step: Install & Init & Config & Generate hexo
Source doc: hexo doc
Install
Recommand using global instal hexo-cli for beginner:
1 | npm install -g hexo-cli |
After that, you can check you hexo version:
1 | hexo -v |
and get such output:
1 | INFO Validating config |
Init
One command: hexo init
, but remember run npm install
1 | hexo init ${FOLDER_NAME} |
Config
A just-init hexo blog folder would seem like:
1 | . |
In _config.yml
:
Generate
1 | hexo gen |
1 | hexo clean |
Second Step: deploy it on GitHub page
For update and deploy the hexo blog in one step:
1 | hexo clean && hexo generate && hexo deploy |
or
1 | hexo clean && hexo generate && hexo server |
But if you deploy firstly, you need to configure the _config.yml
:
1 | # Deployment |
Then run:
1 | hexo deploy |
Last Step: Change your theme
I use this theme: hexo-theme-butterfly
Config theme: butterfly
Afterword: How to writting a blog post?
Source: hexo writting