How to quickly build a blog with Hexo+Github Pages

If you are familiar with how to use Git, then this blog will be set up in no more than an hour. Of course you download resources slowly, when I did not say, hee hee. Of course, if you do not understand, it does not matter, everything starts from 0, I will explain in the article, follow my steps step by step, nonsense less say, start!

Warm prompt

1. First of all, you need to know what your purpose is to build a website. Only when you are motivated, can you have the courage to stick to it and the joy to see the sun through the clouds (when your blog is built).

2. Slow download of resources is a big problem, the following will be solved.

3. If your Github website is slow, I suggest Google or Baidu. After all, it is designed for Google.

4. If there is any problem during the building process, please comment and I will reply as soon as I see it. Advertise: my blog

The article introduction

1. Introduce what to download

2. Install

3. The structures,

4 principle explanation (the reason is put in the last, is to summarize their own, understand its principle, go back to understand deeper, of course, behind beautify blog, also need to know about the principle).

1. Introduce the tools, installation things

If you are impatient, you can skip the installation step. 1. Git: As I understand it, Git can create a local repository on our computer (in this case, our blog repository) and then deploy our web Pages on Github. 2. Node.js: You can’t play without installing it. Because he’s going to install Hexo. 3.Hexo: This thing takes our local Markdown files, files with the suffix.md, and processes them, renders them, and turns them into static web pages, our blogs. All see officials know, slowly install, not installed, blog cool cool.

2. Install tools

(1) Install Node.js

This thing recommends everyone to go to the official website to download, the network is not good suggestion to download a Firefox browser. Enter the official website, directly choose their own number of bits on the line. If you don’t know, go to my computer. I chose Windows 64-bit.

2. Install Git

Git Git Git Git Git Git Git Git Git Git Git Git version = “next”; git version = “next” Git git git git Git Git Git Git Git Git Git Git Git The above is a graphical management tool, because do ugly, we still choose the following command line to operate.

(3) Install Hexo

Since Hexo is hosted abroad, it takes a long time to download, so we use a domestic taobao mirror. Enter the following in CMD:

 npm config set registry https://registry.npm.taobao.org
 npm config get registry//** ** ** *
Copy the code

Install Hexo

 npm install hexo-cli -g
Copy the code

Install the equivalent of a command for Hexo. I’m going to talk about that.

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

The second sentence is install Hexo deployer to git page

Replace the mirror, install the Hexo, and you’re done with the foreplay of building your blog. You can have a cup of coffee, get up and walk.

3. Build a blog

This part, if the Internet speed is good, it will be done quickly, but not good, just wait.

(1) Initialize the blog

First, create a folder of your choice to hold the body of our blog. For example, F: Projects\blog, right mouse click Git Bash Here, go to Git command box, do the following.

hexo s
Copy the code

Just search for localhost:4000 and you’ll have your own blog. That’s what fucking hard work pays off. Of course this is only your local warehouse blog, we write blog is not to pretend B, do not let others see, that can be called pretend B? Cheap, ha ha ha! Are you kidding? Blogging must be a way to improve yourself.

(2) Use of Github

Knock on the blackboard!! Here we go!! If you are familiar with Git, then you can skip this part and learn from it.

First of all, register a Github account, total impossible, with other people’s things, but also do not give others to increase the flow of it, refuse white piao, hee Hee hee, build a good point like you know !!!!

Get to the point, actually don’t think of Github as difficult, it is mainly English that makes you difficult, ha ha ha, if English is poor, Google browser can translate.

Github is actually hosting code. We build libraries on it and push it. We don’t push it on this blog.

(3) Configure the SSH key:

SSH is a protocol, just like HTTPS, guaranteed to be secure. Github needs to know a key. This is a public key. We have a key called a private key. 1. Create a key:

$ssh-keygen -t rsa -c "[email protected]" # Generating public/private RSA key pair. Enter file in which to save the key (/c/Users/you/.ssh/id_rsa): [Press enter]Copy the code

Directly enter

Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]
Copy the code
Your identification has been saved in /c/Users/you/.ssh/id_rsa.
Your public key has been saved in /c/Users/you/.ssh/id_rsa.pub.
The key fingerprint is:
01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@example.com
Copy the code

SSH and pub. This is the public key and the private key is the other one. Copy the contents of the public key, go to Github, click your profile picture, and have a setting to configure the public key.

 $ ssh -T git@github.com
Copy the code
The authenticity 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

Just type yes, and now you’re ready to set the user information

$ git config --global user.name "Making the name"/ / user name
$ git config --global user.email  "Github registered email"// Fill in your email address
Copy the code

Click on your new warehouse below, there is:

deploy:
  type: git
  repository: git@github.com:chenQD123/chenQD-blog.git
  branch: master
Copy the code

Remember there’s a pitfall, which is a space after the colon, which is the rule that if you don’t write a space, the deployment will fail, just like in Python. Then it’s time to deploy your blog to Github.

In Hexo, Hexo generate-deploy generates + deployCopy the code

If “deploy” failed at the beginning of the installation, you should install it again.

ERROR Deployer not found: git
Copy the code

It just needs to be installed

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

(4) Deploy a blog

All you need to do is type in any browser: your project name, for example, I am: Github Pages (chenqd123.github. IO /) Github Pages hosts the blog for us.

(5) Beautify the blog

If you want to make your blog look better, you can change the theme: Hexo’s website recommends changing the theme to a more popular one, which is better documented and makes it easier to start your blog. All you need to do to beautify your blog is click on the open source theme on the official website and go to the Github link for a detailed tutorial, starting with installation. Suggest a rest, the body is the capital of revolution.

4. Implementation principle

First, Hexo: Hexo is a framework for Node.js’s open-source rapiddevelopment blog on Github. So how does Hexo help us do that? Here’s the general principle. Do we start installing Hexo by

npm install hexo-cli -g
Copy the code

Once installed, we use the hexo+ command to manipulate some of the hexo plugins, such as: Hexo server, hexo generate, he actually performs hexo by calling the entry function in hexo cli through Node (for example, ‘hexo init’ can be treated as’ node hexo-cli/entry.js init ‘).

When hexo Server is executed, hexo’s Markdown document is rendered twice and becomes our blog.

1. The first time is to traverse the source file under our root directory, which is the page of our blog. It will output some article objects, which is each page of our blog, etc.

2. The second rendering will go through the file under themes, the content under this file is where we want to beautize and modify, hexo generate will output to generate the public folder under the root directory.

This public is the blog we want to host on Github. When hexo deploy is completed, we will push our blog to Github. Each Github account will have a site and an unlimited number of project sites. Github Pages is the domain name given to us to access our blog. Every time we modify our blog, it is only a submitted public file. Hexo generate generates and Hexo deploydeploypages.

conclusion

That’s it. This is the end of the article, the first time to write such a long blog, encounter problems please comment, I see absolute back! Looking back, we may have encountered a lot of problems during the process of building a blog, but it is the only way to improve ourselves. We should believe that efforts will be rewarded, so Enjoy it. If it helps you, like, like, code so many words, no credit also have trouble ah, woo woo (tore heart crack lung).