This is the second day of my participation in Gwen Challenge

Hi, I’m Daotin, front end team leader. If you want to get more front end highlights, follow me and unlock new front end growth poses.

The following text:

Buy a domain name

You can buy it yourself at sg.godaddy.com/zh/.

2. Configure Github

1. Create CNAME file

Create a new CNAME file in the Sources directory of our Hexo project with our domain name in it.

Then redeploy the project:

hexo g
hexo d

Copy the code

If you are building a blog using hexo and deploying it on Github Pages:

After each hexo g hexo d, the Github Pages repository will push the contents of the public folder in your blog directory to the Github Pages repository and overwrite the CNAME file. To solve this problem, add the CNAME file directly to the source folder. This way you don’t have to worry about overwriting the CNAME file in the warehouse every time you push it.

We can then see this file in the Github project root directory of the site:

Alternatively, on the Github project, click Settings, go to The Custom Domain, fill in the requested domain name, and save. This will also see the file in the Github project root directory, but the CNAME file will disappear every time you deploy the project, essentially putting your new CNAME in the local Github project root directory instead of the source folder.

2. Add records to DNS

Add 3 records to your DNS configuration (in DNS provider, dnspod as an example)

Host(Host record) Record type Points To(record value)
@ A 192.30.252.153
@ A 192.30.252.154
www CNAME username.github.io

In this way, others can access your website with WWW and without WWW (in fact, the way of WWW, will first resolve into XXXX.github. IO, and then become xxx.com according to CNAME, that is, the middle is through a conversion).

CNAME alias record is used in github page, but sometimes the IP address will change, resulting in the final resolution is not correct, so it is recommended to use CNAME alias record is better than IP.

Such as: Github. IO = @@github. IO = xxxx.github. IO = @@github. Replace username with your own Github username.

3. Change the DNS address on GoDaddy

(1) In the drop-down menu of my account in the upper right corner, click -> My Product:

(2) Click the DNS button after the domain name:

(3) Change the DNS server to:

f1g1ns1.dnspod.net 
f1g1ns2.dnspod.net

Copy the code

4) Wait for your DNS configuration to take effect:

The DNS configuration does not take effect immediately. Wait a minute and then visit your domain name to see if the configuration is successful.

Iii. Reference materials

  • How does Github bind its own domain name

  • How to Build an Independent Blog — Concise Github Pages with Hexo Tutorial

  • Set up a static personal blog on GitHub and GoDaddy

(after)

Recent hot articles:

  • Waterfall flow, it’s so easy
  • Four common ajax cross-domain solutions (easy to understand)
  • Vue. Js Naming Style Guide (Easy to remember Version)

Want to see more exciting content, follow me to get more front-end technology and personal growth related content, I believe that interesting people will meet!

It is said that those who give a “like” will be lucky enough to get a promotion and a raise a month later