0、准备工作

  • 下载安装好node.js和git
  • 注册登录github

git绑定用户名和邮箱

在任意文件夹下右键点击Git Bash Here

执行git config --global user.email "<youremail>"git config --global user.name "<username>"

1、搭建仓库

填写仓库信息

★ Repository name为<username>.github.io,例如我的用户名为wq3stone我便填写wq3stone.github.io,我已经搭建过了因此会报错

★ 一定要选择Public,因为你的网站是对外公开的,选择Private别人就看不见了哦

最后点击Create repository仓库就搭建好了

现在可以去<username>.github.io参观一下,展现的是README.md文件中的内容

2、配置sshkeys

生成sshkeys

在任意文件夹下右键点击Git Bash Here,输入ssh-keygen -t rsa -C <youremail>

这里如果没生成过的话会没有Overwrite那一行

绑定sshkeys

据图中所示目录找到id_rsa.pub文件,用记事本打开全选复制

然后打开github

测试是否绑定

打开Git Bash,输入ssh -T git@github.com(...)


以下内容简要概括


三、本地生成

安装hexo

npm install -g hexo

初始化hexo

hexo init

静态生成本地服务器

hexo servehexo s

四、_config.yml中的deploy

1
2
3
type: git
repository: 仓库http地址
branch: main

五、装插件(npm install xxx --save)

hexo-deployer-git(必需) hexo-blog-encrypt(文章加密) hexo-generator-baidu-sitemap(生成百度站点地图) hexo-generator-sitemap(生成站点地图) hexo-abbrlink(生成永久链接)

六、生成页面

hexo generatehexo g

七、上传到github

hexo deployhexo d

该过程需要密码去github的开发者设置中设置token