之前我真的没有打算写这个文章应为,写这个真的浪费我的时间,但是今天突然想搭建hexo发现全部忘掉了,问想还是写一个简单的吧,以后可能自己能用到,下面这个文章可能写的比较简化

安装需要的工具

hexo的初始化

1
2
hexo init      # 初始化
npm install # 安装组件
1
2
hexo g   # 生成页面
hexo s # 启动预览

访问 http://localhost:4000

image-20211104114845097

git配置

1
2
git config --global user.name "你的GitHub用户名"
git config --global user.email "你的GitHub注册邮箱"

ssh密钥

1
ssh-keygen -t rsa -C "GitHub注册邮箱"

如果没有其他的密钥的话可以直接按三次回车

image-20211104113659242

image-20211104113804654

打开密钥文件

image-20211104113833350

进入这个网站添加密钥https://github.com/settings/keys

image-20211104113537343

image-20211104113949360

image-20211104114033445

仓库创建

仓库名用户名.github.io

image-20211104112411748

Hexo部署到 GitHub Pages

安装 hexo-deployer-git

1
npm install hexo-deployer-git --save

修改 _config.yml

1
2
3
4
deploy:
type: git
repository: git@github.com:用户名/用户名.github.io.git
branch: master

上面repository添加的就是下面的这个东西
image-20211104115339118

访问令牌

应为现在提交不要密码了要的就是这个访问令牌不然不能提交

添加令牌

image-20211104115628009

image-20211104115707416

image-20211104115722983

image-20211104115839828

生成出来的令牌只显示一次注意保存

image-20211104115918010

绑定域名

image-20211104141227453

image-20211104141252797