Fork me on GitHub

Hexo同时部署到GitHub与Coding

如何将Hexo博客同时部署到GitHub与Coding,通过调整域名解析实现博客的全局加速?

Hexo博客部署到GitHub

参考之前文章:使用GitHub+Hexo+Next搭建静态博客

Coding介绍

Coding 是一个面向开发者的云端开发平台[1] ,目前提供代码托管,运行空间,质量控制,项目管理等功能。此外,还提供社会化协作功能,包含了社交元素,方便开发者进行技术讨论和协作。
2016年3月CODING宣布收购代码托管平台GitCafe。
官网地址

Coding配置

配置流程说明

新建项目–配置密钥–修改hexo主配置新增Coding仓库–发布代码

新建项目

项目–添加项目–填写项目基本信息–创建项目–Pages服务

配置密钥

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
$ ssh-keygen.exe
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa):
Created directory '/c/Users/Administrator/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/Administrator/.ssh/id_rsa.
Your public key has been saved in /c/Users/Administrator/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:ZWPN5fxsWVkjIQ1lEMz67HgN0bRHZglzpMtKMg4+LgQ Administrator@JHN44SLTQ4950SC
The key's randomart image is:
+---[RSA 2048]----+
| o=*B=+o|
| =o*==+|
| * =.B..|
| E = o.o.+o|
| . .Soo..o..+|
| .. o ++. . |
| . o .o.o |
| .. .. o . |
| .. . |
+----[SHA256]-----+
$ ls -al /c/Users/Administrator/.ssh/
total 17
drwxr-xr-x 1 Administrator 197121 0 十二 20 16:29 ./
drwxr-xr-x 1 Administrator 197121 0 十二 20 17:03 ../
-rw-r--r-- 1 Administrator 197121 1675 十二 20 16:25 id_rsa
-rw-r--r-- 1 Administrator 197121 411 十二 20 16:25 id_rsa.pub
-rw-r--r-- 1 Administrator 197121 1594 十二 20 17:03 known_hosts
$ cat /c/Users/Administrator/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDCw9CPE44v69nKyax5jgyUSL0p60K3HRo8/jnDd2zJk3O4FSKp20BnNMr3V52G4mIHtqP4ymx8rECD0W25ArIuVY7bKmwMKLQDueNrgNfJuA2hsjdQVTPrK7styptKQTGxPWazgRc4Gtd/ARZqSBB4PlwGNeRwPJmHY8pcubnlmEBsdfasdbaaNBAsdfasdf7w28D1fsdfsdfRJZqzQtBkeEy2N+idpueZitD3nmlXj0/PlK0pz7rAU8GI3nnZ429jyUts348atlcSQV7shFUZ7PKzMz/0tr6c7h97euEU4JMKA7+HhIpEqXvcgrQ7Nwgu1v1l97/9rNbZ3DKZ45xLUQ4Q1krgd+5oeiPjbpzJ Administrator@JHN44SLTDFGQ4950SC

将获取的公钥信息添加Coding后台(账号–SSH公钥–新增公钥)

Hexo配置

hexo-deploy-git配置2个以上Git账号
https://www.npmjs.com/package/hexo-deployer-git
我的配置如下:
原配置

1
2
3
4
5
# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
type: git
repo: https://github.com/mds1455975151/mds1455975151.github.io.git

新配置

1
2
3
4
5
6
7
# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
type: git
repo:
github: https://github.com/mds1455975151/mds1455975151.github.io.git
coding: [email protected]:yujianyuanxingk/mds1455975151.git

发布代码并测试

1
2
3
hexo clean
hexo g
hexo d

域名设置

将Coding设置为默认线路解析,将Github设置为海外线路解析

参考资料

hexo干货系列:(四)将hexo博客同时托管到github和coding

======================================================
希望各位朋友支持一下

本文作者:dongsheng
本文地址https://mds1455975151.github.io/archives/dc5d7546.html
版权声明:转载请注明出处!

坚持技术分享,您的支持将鼓励我继续创作!