Using Hexo+ Github to build a personal blog – Environment and Hexo+ Github to build a personal blog – Blog Initialization, we learned about the environment and configuration required to build a personal blog using Hexo. The following article will introduce how to publish our blog to Github.

. GitHub configuration

In Hexo+ Github Build Personal Blog – Environment Build, we have a basic understanding of Github and have set up the basic git environment locally. If we want to publish our blog to Github, we also need to go to Github for user registration.

1.1 registered making

Link: making

1) Click the above link to access the user name, email address and password as shown below, and click Sign Up for GitHub to proceed to the next step

SIHAI

2) As shown in the picture, select the free mode in the red box. Of course, if you have other requirements, you can also choose other modes for payment. Click Finish Sign Up to complete the registration

SIHAI

3) After completing the above steps, your registered email will receive a verification email from GitHub. Log in to your email and click on the email link in the visit email to verify. If you do not receive an activation email, follow the instructions and pictures below:

  • Click the drop-down menu at mark 1 and select Setting
  • Click the Emails at label 2
  • Click Resend at 3 to Resend the verification email


    SIHAI

1.2 Adding an SSH Key

After registration, we need to add our SSH Key to GitHub in order to enable our computer to directly access GitHub through SSH without password. First we need to open the terminal, follow the steps below. 1) Run the following command to check whether the SSH Key exists on the terminal

$ ls -al ~/.ssh

Copy the code

If your computer already has an SSH Key, the terminal will display the following information. Skip step 2 and go to step 3.

OUYANGSIHAI:~{k}{e}{v}\in${l}{s}-{a}{l}~/.ssh/

total 80

drwx------ 9 kevin staff 306 Aug 23 23:51 .

drwxr-xr-x+ 45 kevin staff 1530 Sep 4 00:28.

-rw------- 1 kevin staff 1679 Aug 9 2014 id_rsa

-rw-r--r-- 1 kevin staff 399 Aug 9 2014 id_rsa.pub

Copy the code

2) Run the following command to generate an SSH Key

$ ssh-keygen -t rsa -b 4096 -C "[email protected]"

Copy the code

Note: We recommend using the default configuration, so if prompted next

Enter file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]`

Copy the code

or

Enter passphrase (empty for no passphrase): [Type a passphrase]

# Enter same passphrase again: [Type passphrase again]

Copy the code

We just press Enter

3) Add the SSH Key to the Ssh-agent

$ eval "$(ssh-agent -s)"

$ ssh-add ~/.ssh/id_rsa

Copy the code

4) Copy the SSH Key to the clipboard

  • Method 1: Use the pbcopy command. If your computer does not support this command, you can use method 2
$ pbcopy < ~/.ssh/id_rsa.pub

Copy the code
  • Method 2: Run the cat command to read the contents displayed on the terminal, and select the SSH Key displayed on the terminal to copy
$ cat < ~/.ssh/id_rsa.pub

Copy the code

5) Add the SSH Key we just copied to the account

  • Click the drop-down menu at mark 1 and select Setting
  • Click SSH Keys at 2
  • Click Add SSH Key at mark 3. At this time, the content of mark 3 will be displayed
  • We can name the Title whatever we want according to our specifications, and we can copy the SSH Key we just copied into the Key
  • Click Add Key at mark 5 to save


    SIHAI

6) Run the following command to check whether the SSH Key is successfully added

$ ssh -T [email protected]

Copy the code

When executing, the terminal will prompt you with the following information. Enter yes

TheAuthenticity of Host 'github.com (207.97.227.239)' can't be established.

# RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.

# Are you sure you want to continue connecting (yes/no)?

Copy the code

If added successfully, the terminal will output

Hi username! You've successfully authenticated, but GitHub does not

# provide shell access.

Copy the code

1.3 the new Repository

Finally, we need to create a Repository for hosting our blog. The Repository name must follow the following conventions

username.github.io

Copy the code

For example, if my user name is OUYANGSIHAI, my Repository name must be Ouyangsihai.github. IO

Write the picture description here


At this point, our GitHub configuration is complete.

. Second, Hexo configuration

To make it easy to deploy your blog to GitHub, Hexo provides the Hexo-Deployer-git component, which is explained briefly below.

2.1 Configuring the Deploy Plug-in

1) Open the _config.yml file in the root directory of our blog and set the deploy information. Be sure to replace the repository link with the repository link you see

deploy:

type: git Set the release type, such as git

repository: [email protected]: OUYANGSIHAI/ OUYANGSIHAI.github.io.git Set the link for repository

branch: master Set the branch to submit to

message: Site updated at {{ now("YYYY-MM-DD HH:mm:ss")}}# Set the information we submit

Copy the code

2.2 release

1) Run the following command to generate a static page for the blog

$ hexo g # is the same as hexo generate, g is short for generate

Copy the code

2) Run the following command to upload our generated static page to GitHub

$ hexo d # is the same as hexo deploy, and d is short for deploy

Copy the code

Github. IO is a blog that we have just deployed to Github. For example, mine is Ouyangsihai.github. We just need to continue with step 1 and Step 2 above to generate static pages and deploy them to GitHub. If you encounter some resource errors or other problems, you can run the following command to clear the generated static files, and then perform step 1 and Step 2 again.

$ hexo clean Delete static pages that have been generated

Copy the code

. Third, concluding remarks

So far, we have successfully built our own personal blog using Hexo+ Github, which is very simple and can be used to express your talents. You are sure to be good!

If there are any improper articles, please correct them. You can also pay attention to my wechat public number: Learn Java well and get high quality resources.