Click “Read the article” at the bottom of this article to see my blog based on Hexo + GitHub Pages!

Preface: My blog writing road

  • 15 years just went to the university, contact public number for the first time, initiated to create a public number to write something, but ultimately failed.

  • Soon, in 2016, I started to contact various major blog websites on the Internet, and CSDN was the most popular one. I started to register a blog to write about my problems in learning and share some of my solutions, but it never came to an end.

  • In the summer vacation of 2016, we media was rampant all over the country. I seemed to see a lot of opportunities in my eyes, but it seemed to be extremely vague. By chance, I realized that I had to start a blog to write something. At that time, I thought that I should register a toutiao number first and then start a blog to write something when the school starts in the second half of 2016. This kind of thing is not in a hurry and time goes by.

  • As the clock ticks down to 2017, the first half of the year is still buzzing with the sign-up, blogging mentality, but not much action.

  • Finally, around June, 2017, I went to a place and came back in a hurry. I immediately registered a blog on the online platform and began to write about my study. Then I quickly registered a wechat official account, and began to record my students and life with the keyboard for the first time, which was the beginning of my blog and writing that HAD been delayed for two and a half years.

  • A blog platform for online advertising a lot, I have no way to adapt to at the beginning, don’t know how to layout, combined with the typing speed and turtle rate were similar, that is, to write an article on the hundreds of words to an hour or two, also don’t know if I write something, but also know, for the first time writing the harvest is so great that concrete to say the last three days and three nights, just here.

  • Slowly began to build a personal blog of their own, so eager to get quick results and instant benefits, shallow hiding various programming languages, and finally failed, nothing.

  • With the poor foundation of the Java language, I began to learn the framework and build a blog. Although there are all kinds of abnormal errors and garbled code problems, I still want to give up, but I am not willing to do so, so I am still learning.

  • After slowly sifting through various information such as WordPress, CNBlogs, short books and nuggets, I finally chose to build a blog framework of Hexo + GitHub Pages.

Build personal blog based on Hexo + GitHub Pages

1. Preparation before construction

Git installation: Git is the most advanced distributed version control system in the world, which can handle project version management from very small to very large effectively and quickly.

(1) Download Git: download it from the official website (all major system versions have Git, here take Windows version as an example)

(2) Double-click the downloaded Git installation package to start the installation

(3) Keep clicking Next to continue installation

git --versionCopy the code

(6) Recommend two websites to learn Git:

  • Official documentation: Click here to go

  • Liao Xuefeng website tutorial: Click here to go

    

2. Install Node.js: It is a lightweight and efficient JavaScript environment based on Chrome V8 engine. Node.js package manager NPM is the world’s largest open source library ecosystem.

(1) Download Node.js: download from the official website (available in all major system versions, Windows as an example)

(2) Double-click the downloaded Node.js installation package to start the installation

(3) Keep clicking Next, select the installation path, and continue the installation

(4) Click Install to complete installation

(5) Open the CMD window and run the following command to display the Node.js version

node -vCopy the code

Build Hexo blog

  1. Install Hexo, create a compassBlog folder on your computer to store your blog, right-click Git Bash inside the folder to go to the command window, and execute the following code:

npm install -g hexo-cliCopy the code

The results are shown below:

2. Initialize Hexo to get the Hexo folder, which is used to store all the Hexo blog files, including the theme files described below. Git Bash window executes the following code:

hexo init hexoCopy the code

The results are shown below:

3. Configure Hexo, enter the Hexo folder to install dependencies, deploy the resulting files, and execute the following code respectively:

cd hexonpm installhexo generateCopy the code

The results are shown below:

4. Start the server: Execute the following code, you can see the server code is 4000

hexo serverCopy the code

The result is shown below: Press Ctrl + C to stop the server

5. Open the browser and enter http://localhost:4000/ in the address bar. The result is shown in the following figure

Deploy the initialized Hexo blog to GitHub Pages

1. Create a Github account and create a repository named compassblog.github. IO, as shown below: (Since my repository has been created, it will show that the repository already exists, and the name of the repository must be strictly in the format of username.github. IO)

2. Go to the repository, click Settings, find the GitHub Pages option, click Choose a Theme to select a theme, and then click Select Theme to select a theme, as shown below: (At this point, you can already access the theme of your choice in the address bar. You can skip the theme selection step, but I think GitHub’s theme is pretty cool, so I’ll add this step instead.)

3. Configure Git personal information: Open a Git Bash window in the Compassblog directory and type the following command

Git config --global user.email git config --global user.email git config --global user.emailCopy the code

As mine is as follows:

4. Generate an SSH KEY, which is a public KEY and a KEY. GitHub needs a KEY to connect to the local server. Run the following command and press Enter three times to generate a key:

Ssh-keygen -t rsa -c "email address"Copy the code

My computer is as follows:

5. After the SSH KEY is generated, it is saved in C:/Users/ computer name User name /. SSH by default.

6. Open GitHub, click profile picture ->Settings- >SSH and GPG keys- >Add SSH key, paste the copied key into the key input box, click Add Key, SSH key configuration is successful, as shown in the picture below:

7. Modify the _config.yml global configuration file in the hexo folder and modify the deploy property code to host the local Hexo project on GitHub, as shown below:

Deploy: type: the type of git # deployment repository: [email protected]: compassblog/compassblog lot. IO. Git # branch warehouse address: Master # branch name message: hexo deploy # commit messageCopy the code

8. Run the following command to install the hexo-deployer-git plug-in and quickly host the code on GitHub

npm install hexo-deployer-git --savaCopy the code

The result looks like this:

9. Execute the following code command to host the Hexo project on GitHub

hexo clean && hexo generate && hexo deployCopy the code

Note: Hexo generate can be abbreviated as Hexo G and hexo deploy can be abbreviated as Hexo D

The result looks like this:

10. Your browser address bar enter https://username.github.io/ access, you can see the blog has been deployed to making, normal access, as shown in the figure below:

Write a few last words

I originally wanted to publish the process of building personal blog based on Hexo + GitHub Pages in one post, but it was too long. There are many configurations about how to change the theme of the blog, how to change the personality of the blog, the specific configuration, etc. I will continue to publish them at a later time. Thanks.

Recommended reading:

  • Python from the beginning to the basics exercise 15 questions

Every step of growth, want to record and share

Click on follow to learn more