First to Hexo (Building Blog using Hexo and Github)
Hexo Installation
- Environment: Ubuntu=24.4
Install Node.js
use nvm
1 | |
Other methods can be found in Nodejs website.
Install Git
1 | |
Install Hexo
make a folder for Hexo
1 | |
install hexo-cli
1 | |
It take a while, because the node_modules has a reputation for being too bloated.
Hexo Usage
Initialize Hexo
goto blog folder
1
cd blogedit config
use vi:
1
vi _config.ymlor vscode:
1
code _config_ymlchange the title, subtitle, author and url…
for example:
1
2
3
4title: dyliu's Blog
subtitle: 'Documenting my personal experience'
author: dyliu
url: https://yourname.github.io/
Create blog page
new page
1
hexo new "First-to-Hexo"edit page in vscode (or something else)
1
code source/_posts/First-to-Hexo.md
Preview the page
use
1 | |
to start a local server http://localhost:4000
Deploy on Github
Create Github repository
Sign in (or sign up first) and Create new repository
It’s name should be
yourname.github.io, whereyournameis same with your github username, for example ‘dyliu0312.github.io’ in my case, to get to the page simply usinghttps://dyliu0312.github.io.Otherwise, it’l be
http://yourname.github.io/your_repository_name.github.io.Generate ssh key
git config
1
2git config --global user.name "yourname"
git config --global user.email "youremail"use
1
ssh-keygen -t ed25519 -C "your_email@example.com"to generate a pair of ssh key in local machine.
- Add ssh key to repository
Open the public key
.ssh/id_ed25519.pub, and copy the context.Turn to repository page, click
Settings, and then clickDeploy keysinSecurityto save new ssh key.
Edit config
revise the _config.yamlfile:
1 | |
Deploy
Install hexo-deployer-git
1
npm install hexo-deployer-git --saveClean
1
hexo cleanGenerate
1
hexo gDeploy
1
hexo d
Reference
https://blog.csdn.net/weixin_43883917/article/details/143885553
https://training.github.com/downloads/github-git-cheat-sheet/
https://blog.csdn.net/m0_53127626/article/details/136090280
https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent
https://mini-pi.github.io/2024/02/28/how-to-make-blog-wedsite/