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, and I seemed to see many opportunities in my eyes, which 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, 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 Page

1. Preparation before construction

1. Install Git: 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

(4) Click Install to complete installation

(5) Open the CMD window and run the following command. The Git version is displayed. The installation is successful

git --version
Copy the code

(6) Recommend two websites to learn Git:

  • Official documentation: Click here to go
  • Liao Xuefeng website tutorial: Click here to go

Node.js is a lightweight and efficient JavaScript runtime 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 -v
Copy 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-cli
Copy the code

The results are shown below:

Git Bash: “Hexo”, “Hexo”, “Hexo”, “Hexo”, “Hexo”, “Hexo”, “Hexo”, “Hexo”

hexo init hexo
Copy 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 hexo
npm install
hexo generate
Copy the code

The results are shown below:

4, Start the server: execute the following code, you can see that the server port number is 4000

hexo server
Copy the code

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

5. Open the browser, enter http://localhost:4000/ in the address bar, and the result is shown in the following figure. You can see that the initial Hexo blog is successfully set up and accessible

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.name "GitHub username"
git config --global user.email "GitHub Email"
Copy the code

As mine is as follows:

GitHub needs a public 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. The SSH KEY is saved in C:/Users/ computer name user name /. SSH by default.

6. Open GitHub, click profile picture ->Settings- >SSH and GPG keys- >New SSH key, paste the copied key into the key input box, and click Add Key. The SSH key is configured successfully, 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: git		Type of deployment
  repository: [email protected]:compassblog/compassblog.github.io.git # Warehouse address
  branch: master		# branch name
  message: hexo deploy	# Submit information
Copy the code

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

npm install hexo-deployer-git --sava
Copy the code

The result looks like this:

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

hexo clean && hexo generate && hexo deploy
Copy 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, the 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 wanted to publish the Hexo + GitHub Pages personal blog process in one post at a time, but it was too long to write in one post. How to change the theme of the blog, how to change the personality, specific configuration and so on a lot of configuration, later find time to continue to release, welcome to pay attention, Thanks.

Scan the QR code to follow the wechat official account to learn more