前期准备

1.Node.js

https://nodejs.org/en/

https://nodejs.org/dist/latest-v12.x/

注意版本不要大于12.x,否则hexo s会有报错

2.Git-Bash

http://git-scm.com/

3.编辑器

VScode、Sublime、Typora(推荐)

部署过程

打开git-bash

$ npm install hexo-cli -g

打开网站目录,初始化hexo环境

$ hexo init

启动hexo 服务

$ hexo s

打开localhost:4000,本地预览博客

安装git deploy插件

$ npm install hexo-deployer-git -g

配置git仓库

$ git config --global user.name "luanxinchen"
$ git config --global user.email "1102026400@qq.com"

生成rsa公钥

$ ssh-keygen -t rsa -C '1102026400@qq.com'
$ cat ~/.ssh/id_rsa.pub

将生成的公钥上传至github

image-20210403163434375

修改配置文件,更改github远端仓库为自己的gitpage

$ vim _config.yml
​
# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
  type: git
  repository: https://github.com/luanxinchen/luanxinchen.github.io
  branch: master

推送分支

$ hexo g -d

推送成功后打开gitpage,刷新几次后即可看到更新内容