在hexo本地实施没有问题的基础上
hexo-deployer-git
插件。在命令行(即Git Bash)运行以下命令即可:
$ npm install hexo-deployer-git --save
3.2. 添加SSH key。
C:\Users\Administrator\.ssh\id_rsa.pub
),粘贴到New SSH Key即可。 3.3. 修改_config.yml
(在站点目录下)。文件末尾修改为:
# Deployment## Docs: https://hexo.io/docs/deployment.htmldeploy: type: git repo: git@github.com:<Github账号名称>/<Github账号名称>.github.io.git branch: master
注意:上面仓库地址写ssh地址,不写http地址。
3.4. 推送到GithubPages。在命令行(即Git Bash)依次输入以下命令, 返回INFO Deploy done: git
即成功推送:
$ hexo g$ hexo d
https://<Github账号名称>.github.io
至此,您的Hexo博客已经搭建在GithubPages, 域名为https://<Github账号名称>.github.io
。
在方案一的基础上,添加自定义域名(您购买的域名)。
https://github.com/<Github账号名称>/<Github账号名称>.github.io/settings
2.2. 在Custom domain下,填写自定义域名,点击save
。
2.3. 在站点目录的source
文件夹下,创建并打开CNAME.txt
,写入你的域名(如www.simon96.online
),保存,并重命名为CNAME
。https://<Github账号名称>.github.io
依然可用。GithubPages 在国内较慢,百度不收录,而CodingPages 在国外较快。所以在方案二的基础上,添加CodingPages 。
C:\Users\Administrator\.ssh\id_rsa.pub
), 粘贴到新增公钥。
4.2. 测试是否添加成功。在命令行(即Git Bash)依次输入以下命令,返回“You’ve successfully authenticated”即成功:
$ ssh -T git@git.coding.net$ yes
4.3. 修改_config.yml
(在存放Hexo初始化文件的路径下)。文件末尾修改为:
# Deployment## Docs: https://hexo.io/docs/deployment.htmldeploy:- type: git repo: git@github.com:<Github账号名称>/<Github账号名称>.github.io.git branch: master- type: git repo: git@git.dev.tencent.com:<Coding账号名称>/<Coding账号名称>.git branch: master
4.4. 推送到GithubPages。在命令行(即Git Bash)依次输入以下命令, 返回INFO Deploy done: git
即成功推送:
$ hexo g$ hexo dhttps://dev.tencent.com/u/<Coding账号名称>/p/<Coding账号名称>/git/pages/settings
)中绑定自定义域名。至此,您的Hexo博客已经解析到自定义域名,https://<Github账号名称>.github.io
和https://<Coding账号名称>.coding.me
依然可用。
和 git类似
root,url中需要手动设置仓库路径
如
url: http://pythonywy.gitee.io/my-blog root: /my-blog/
已经主题设置里面的所有样式链接如果加载不出来开头加上/仓库名称/