Deploy the Hexo personal blog to both GitHub and Coding

1. Host your personal blog on GitHub

Regarding how to quickly build your own personal blog, how to improve your own personal blog, what is GitHub, how to host your own blog code on GitHub, etc., I have written three articles before and have given detailed instructions, three The article is as follows:

Build a personal blog based on Hexo + GitHub Pages (1)

Build a personal blog based on Hexo + GitHub Pages (2)

Build a personal blog based on Hexo + GitHub Pages (3)

2. Host your personal blog on Coding

There was something wrong with the blog recently. I have been repairing it urgently these days. I have been tossing my blog non-stop, and then it is not good. I am very curious today, so I logged into Baidu Statistics and found a problem, that is, Baidu cannot crawl and host it on GitHub. The blog on Pages may be because GitHub is a foreign code hosting platform that cannot be crawled, and then it is a bit depressing... As shown in the following figure:

Then I checked on Google and found that there is a code hosting platform in China called Coding, which can also host personal Hexo blogs on the platform. Then I was a little excited and said that it was too late, so I immediately started to try to host my personal blog to On Coding, I encountered many pits in the middle, after a long time of tossing, and finally succeeded, hereby record.

It is understood that many people used to host their blogs on gitcafe in China, and then 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 if Code Cloud can host personal blog codes. It's GitHub, you can learn about it yourself if you need it.

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 under the C drive user of the following computer, find the id_rsa.pub file, which is the public key file, and copy all the contents of the file, as shown in the following figure:

(2) On the logged-in Coding website, open the personal settings, click the new public key under the SSH public key menu, and then paste all the copied content into the public key content box. The public key name is customized, there is no special requirements, and then click Add, as shown below:

(3) Test whether the SSH public key is added successfully: Open the Git Bash window locally and enter the following command:

ssh -T [email protected]

At this time, it will display whether to continue. Select yes to continue. If the following prompts are successful, the SSH public key configuration is successful:

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

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

As shown in the figure:

It means that the firewall completely blocks port 22. Don't panic at this time, just enter the following command and use the 443 port SSH service provided by Coding to solve the problem:

ssh -T -p 443 [email protected]

As shown below:

Then enter the verification command to display the Coding account and related information, that is, the SSH public key is successfully configured.

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

(1) Click the + sign on Coding's personal homepage and select the item option, as shown in the following figure:

(2) After selecting the new project, fill in the project information, the project name and your own Coding account name project, the project properties can be public or private, and the personal blog is recommended to be public, as shown in the following figure:

(3) After the new project is completed, open the Pages service option of the project, select the deployment source as the master branch, and open the Force HTTPS access button (https is more secure). If you don't select it, you can access it by HTTP. You can decide if you don't. Click to save, as shown below:

4. Configure the main blog file and deploy the Hexo blog to GitHub and Coding

(1) Open the Hexo blog main configuration file _config.yml, find the deploy attribute, and configure as follows:

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

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

5. Test whether the Hexo blog is successfully deployed to GitHub and Coding

After the previous steps, the configuration is basically completed. Open the Git Bash window directly in the Hexo home directory and enter the following command:

hexo clean && hexo g && hexo d

As shown below:

The deployment is successful, enter the GitHub address and Coding address in the browser address bar, and the access is successful:

https://compassblog.github.io/

https://compassblog.coding.me/

Scan the QR code and follow the WeChat public account to learn more

--------------------------------------------

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324771255&siteId=291194637