Host your blog on GitHub

I have written three articles about how to quickly build my own personal blog, how to improve my own personal blog, what is GitHub, how to host my blog code on GitHub and so on, which have made detailed explanations. The three articles are as follows:

Hexo + GitHub Pages

Hexo + GitHub Pages

Hexo + GitHub Pages

2. Host your personal blog on Coding

There is something wrong with my blog recently, and I have been trying to fix it urgently these days. I have been constantly trying to fix my blog, and then I made a mistake. Today, I am very curious, so I log on Baidu and find a problem, that is, Baidu cannot capture the blog hosted on GitHub Pages. Maybe it’s because GitHub is a foreign code hosting platform that can’t crawl, and then it’s a bit depressing… As shown below:

Then I looked it up on Google and found that there was a code hosting platform called Coding in China, which could also host personal Hexo blog on the platform. I got a little excited and immediately tried to host my personal blog on Coding. For the record.

Many people used to host their blogs on Gitcafe in Korea before Gitcafe was acquired by Coding. Of course, as far as I know, there are other code hosting platforms in China, for example, there is a code hosting platform called code Cloud, but I don’t know whether the code cloud can host the code of personal blog. I don’t use the code cloud much, but basically use GitHub. If necessary, I can learn about it by myself.

1. Register a Coding account

Registration website: Coding official website

2. Configure the SSH public key of this computer to Coding

(1) Open the.ssh directory of the user on disk C of the following computer, find the id_rsa.pub file, that is, the public key file, and copy all contents of the file, as shown in the picture below:

(2) On the Coding website you have logged in, open personal Settings, click Add Public key under SSH Public Key menu, and paste all the above content into the public key content box. The public key name can be customized without special requirements, and then click Add, as shown in the figure below:

$Git Bash = $Git Bash = $Git Bash = $Git Bash

ssh -T [email protected]
Copy the code

If yes is displayed, the SSH public key is configured successfully:

Hello compassblog You've connected to Coding.net by SSH successfully!
Copy the code

Of course, compassblog is the name of my Coding account, different accounts will be different, if the following error is displayed:

ssh: connect to host coding.net port 22: Connection refused
Copy the code

As shown in figure:

Port 22 is completely blocked by the firewall. Enter the following command to use the SSH service for port 443:

ssh -T -p 443 [email protected]
Copy the code

As shown below:

After entering the authentication command, the Coding account and related information are displayed, indicating that the SSH public key is successfully configured.

3. Create a new project to store the blog code that needs to be hosted

(1) Click the + sign on the personal homepage of Coding and select the project option, as shown in the picture below:

(2) After selecting a new project, fill in the project information, including the project name, the name of your Coding account, and the project attribute, which can be public or private. It is suggested to make personal blog public, as shown in the picture below:

(3) After the completion of the new project, open the Pages service option of the project, select the deployment source as the Master branch, and open the forced HTTPS access button (HTTPS is more secure). If you do not select HTTP access, you can also choose it by yourself, and click Save, as shown below:

4. Configure the blog master file and deploy Hexo blogs to Both GitHub and Coding

(1) Open the Hexo blog master config file _config.yml, locate the deploy property, and configure the following:

deploy:
  type: git
  repository:
      github: [email protected]:compassblog/compassblog.github.io.git
      coding: [email protected]:compassblog/compassblog.git
  branch: master
Copy the code

(2) open the source file in the Hexo home directory and create a file Staticfile, which is the symbol of Coding Staticfile deployment. Note that the file name must be Staticfile, otherwise Staticfile deployment cannot be completed on Coding, as shown in the following figure:

5. Test whether Hexo blogs are successfully deployed to GitHub and Coding

After the previous steps, the configuration is almost complete. Directly open the Git Bash window in the Hexo home directory and type the following command:

hexo clean && hexo g && hexo d
Copy the code

As shown below:

If the deployment is successful, enter the GitHub address and Coding address respectively in the address bar of the browser.

compassblog.github.io/

compassblog.coding.me/

Scan the QR code to follow the wechat official account to learn more