安装Git

Git验证
1
git --version

安装nodejs

nodejs验证
1
node -v

安装Hexo

hexo安装
1
npm install hexo -g
hexo验证
1
hexo -v

配置ssh key

  • 生成ssh key
ssh key生成(连按三次回车)
1
ssh-keygen -t rsa -C "邮件地址"
  • 将id_rsa.pub中的内容全部拷贝到Github个人页中的NewSSHKey中
ssh key验证(输入yes)
1
ssh -T git@github.com

新建Github仓库

  • 仓库名为“Github用户名.github.io”

初始化Blog目录

  • 在Blog目录输入以下指令
blog目录初始化
1
hexo init

安装Hexo依赖

hexo依赖安装(需在Blog目录安装)
1
npm install --save hexo-deployer-git

配置_config.yml

  • 修改博客目录下的_config.yml文件
_config.yml
1
2
3
4
deploy:
type: git
repository: git@github.com:Github用户名/Github用户名.github.io.git
branch: main

  • 新建博客:hexo n
  • 生成博客:hexo g
  • 部署博客:hexo d
  • 预览博客:hexo s
  • 去掉Git提交时的换行警告
移除换行警告
1
git config --global core.autocrlf false