Hexo blog Github, Gitee synchronization

Github is still slow to visit in China, although we have moved all the static resources we can get to JSDelivr, which has a domestic node. Here we decided to build a mirror image of the blog on Gitee, so that if the domestic visit is too slow, we can access the website from Gitee, which is "Code Cloud".

First of all, you must log in to your Gitee account. If you don’t have one, you need to register. To create a new warehouse, the warehouse name and the same name as this subpath must be entered. When the site is released, the address generated by the system is the address of this subpath. The automatic route generation can be ignored.

Then set up password-free updates like Github.

We need to add the remote address of Gitee in the configuration of the local code of the Hexo site. This is a display warehouse, we don't need to manually add code to Gitee's warehouse.

Directly in the _config.ymldocument which the repoinside githubof the re-start a new line, fill out the warehouse SSH address. But submitting at this time will find that the Github branch has become gh-page. The branch used for the release site is master, which causes confusion, so the point that needs to be emphasized here is how to specify the corresponding branch when Hexo pushes to multiple remote warehouses.

You cannot use a separate branchattribute here, you need to use another format to specify the branch of the remote warehouse.

gitee: [email protected]:[用户名]/[仓库名].git,[分支名]

Each warehouse must add the corresponding branch.

The complete deployconfiguration is as follows:

# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
  type: git
  repo:
    github: [email protected]:[Github用户名]/[Github仓库名].git,master
    gitee: [email protected]:[Gitee用户名]/[Gitee仓库名].git,master

Go to the Gitee page to open the warehouse, select the above service-Gitee Pages, select the masterbranch, and leave the deployment directory blank . It is best to check Force HTTPS. Then click Deploy. Pay attention to check the deployed URL to see if the subpath is consistent with the Github subpath.

Similar methods can also be deployed to more websites such as Coding, Gitlab, etc., so I won't repeat them here.

Guess you like

Origin blog.csdn.net/qq_35977139/article/details/107755648