Hexo 基础命令
安装与初始化
1 2 3 4 5 6 7 8
| npm install hexo-cli -g
hexo init <folder>
npm install
|
开发与预览
1 2 3 4 5 6 7 8 9 10 11
| hexo generate
hexo server
hexo server -p 4000
hexo g && hexo s
|
部署
1 2 3 4 5 6 7 8
| npm install hexo-deployer-git --save
hexo clean && hexo generate && hexo deploy
hexo d
|
Git 配置指南
全局配置
1 2
| git config --global user.name "Your Name" git config --global user.email "your_email@example.com"
|
SSH 密钥生成
1 2 3 4 5 6 7 8
| ssh-keygen -t rsa -C "your_email@example.com"
cat ~/.ssh/id_rsa.pub
ssh -T git@github.com
|
远程仓库管理
1 2 3 4 5 6 7 8 9 10 11
| git remote -v
git remote add origin https://github.com/username/repo.git
git remote rm origin
git remote set-url origin https://github.com/username/repo.git
|
提交代码
1 2 3 4 5 6 7 8
| git add .
git commit -m "commit message"
git push origin main
|
Hexo 部署配置
编辑 _config.yml:
1 2 3 4
| deploy: type: git repo: https://github.com/YourName/YourName.github.io.git branch: main
|
.gitignore 配置
1 2 3 4 5 6 7
| .DS_Store Thumbs.db db.json *.log node_modules/ public/ .deploy*/
|
常见问题
恢复 Hexo 项目
1 2 3 4
| git clone <repo-url> cd <repo-name> npm install npm install hexo-deployer-git --save
|
强制推送
修改分支名称
这份手册涵盖了 Hexo 日常开发和部署的所有常用命令,建议收藏备用!