Use GitHub pages to build a static personal website and bind a domain name

Use GitHub pages to build a static personal website and bind a domain name

1. Introduction

I recently learned some knowledge related to web development, so I want to practice what I have learned. After all, practice is the only criterion for testing the truth. So, I want to practice what I have learned by systematically making a personal website, but to build a website requires a series of things such as host, domain name, etc., and I just do it for learning and practice, obviously it is not necessary After paying such a high cost, after some searching and planning, an overall idea was formed: use GitHub pages to build a personal static website, and then write some blogs. On the one hand, these blogs can summarize some of the knowledge I have learned, and on the other hand Aspects can practice or experiment the web knowledge I have learned. And once I have the ability to buy a virtual host, these static pages can also be used in conjunction with the background, which also allows me to have more thinking and practice on reserving the background interface.

2. Preparation

1. Register a GitHub account

Enter GitHub official website: https://github.com/

As shown in the figure below, enter the user name, email, and password to register:

GitHub registration page

Then select free in the second step, which is free, as shown in the following figure:

Choose a free plan

Then you can verify by email.

2. Install Git

Download and install Git: https://git-scm.com/downloads

As shown in the figure below, select the relevant system for Git download:

Download Git for the corresponding system

Then install Git like a normal software. Regarding the use of Git, I won't repeat it here. Our focus here is not this, and how to use Git is not something that can be explained in a few words. You must learn how to use Git in detail, at least understand the basic usage of Git.

3. Buy a domain name (optional)

When we use GitHub pages to create a personal website, GitHub pages will have a domain name based on your GitHub username, but this domain name may not be what you want. At this time, you need to pay for a domain name. After purchasing Then bind it to the GitHub pages you created. A simple domain name generally costs only a few ten dollars for the first year.

3. Create, set up GitHub pages and bind a domain name

1. Create a warehouse

After logging in to your GitHub, let's create a repository: https://github.com/new , our static website will be placed here, one thing to note here is: when we use GitHub pages to create a personal static website , the name of the repository can only be "your GitHub username.github.io", and this repository can only have one.

As shown in the figure below, it is the creation process:

Create a GitHub pages repository

2. Set up the warehouse

After creation, create your new warehouse, and then select settings to set the warehouse, as shown in the following figure:

Set up warehouse

Here, you can set your website template or bind your domain name. We can select a template first, save the settings, and then enter your domain name to verify that the creation is complete.

One thing to note here is that you cannot enforce HTTPS settings when setting, otherwise there will be errors during remote cloning and push.

3. Conduct website development

In the previous step, we have used GitHub pages to create a website homepage. The next step is to use Git to clone the warehouse code to the local, and then develop the static website. After the development is completed, it can be pushed to the remote.

If: SSL certificate problem: self signed certificate appears during the clone process, it is because the domain name lacks the ssl certificate. Here, we can cancel the verification of the ssl certificate and enter on the Git command line:

set GIT_SSL_NO_VERIFY=true git clone

After we develop the website locally, we need to push it to GitHub remotely, but we need to enter the username, password and email address when pushing. If the email address you bind is set to private, an error will be reported here. We need to set another email address or use the Un-private the mailbox, find the email option in the user settings, and uncheck it:

Set mailbox permissions

Set the bound mailbox in the local Git command line:

Set the command to bind the mailbox

4. Domain name binding (optional)

Buy a domain name, select a domain name service, find the domain name you bind and select resolve, and then modify it, select A for the record type, enter @ for the host record (ie, empty), and enter the record value into the fixed value assigned to you by our GitHub pages IP (you can see your IP address by pinging your domain name), the resolution route can be defaulted, TTL is 10 minutes, and then enabled.

Then in the warehouse settings mentioned earlier, find Custom domain, enter the domain name you purchased and parsed, and save it:

Save the bound domain name

The resolution and binding of the domain name takes a certain amount of time, and it does not take effect immediately, and there may be a problem that the domain name cannot be used without real-name authentication in the Tianchao domain name. If the process is slow, it may take one to two days. . .

Fourth, the last

GitHub is constantly updated, so what I said above may change with different locations of the version, but the general idea is the same. Use GitHub pages to build a personal static website. There are instructions on GitHub for these processes. Refer to the instructions to build a static website, and you can solve the problem when you encounter problems.

Guess you like

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