Build GitHub static blog

Time:2020-3-31

Minimalist style blog = windows + hexos + GitHub
This is the finished map of this tutorial

Build GitHub static blog

Blog building is divided into three steps:

  • Create GitHub domain name and space
  • Git, nodejs, hexo download and installation
  • Configuration environment

1. Create GitHub domain name and space

Enter GitHub official website, register and log in.
After logging in, click the “+” sign in the upper right corner and select “new repository”, the following interface will appear:

Build GitHub static blog

Fill in username.github.io in repository name. (username refers to the user name of the previous owner. For example, I should fill in wenjie710.github.io here.)
Then click Create repository at the bottom.
2. Install git, nodejs, hexo
Download address:
Download on git official website: https://git-scm.com/download/win
Download on nodejs official website: https://nodejs.org/en/download/
The above two tools are directly downloaded exe files. Click Install. After installation, right click in the folder and you will see a git bash in the drop-down menu. This is a terminal similar to liunx, which can simulate the operation of the terminal under Linux.
You cannot install hexo until GIT and nodejs are installed. The installation of hexo is very simple. You only need to enter the following command in the command prompt (CMD).

npm install -g hexo-cli

3. Configuration environment
3.1 configure SSH
Open git Bash and execute the following command to generate SSH access private key and public key.

ssh-keygen -t rsa -C "[email protected]"

After entering the command, you will be prompted to enter something, regardless. Just keep going back to the end. Then you will generate two files id_rsa and id_rsa.pub under the ~ /. SSH file.

Build GitHub static blog

Open GitHub – > setting – > SSH keys. Then click New SSH key to create a new SSH key. Copy and paste all contents in the file id_rsa.pub under the key. Then use the following command to test whether you can connect to GitHub

ssh -T [email protected]

3.2 write configuration and publish blog
3.2.1 theme installation
Create a new folder to store blogs

hexo init [email protected]

Install the theme. Next is recommended. You can choose other topics.

cd [email protected]
git clone https://github.com/iissnan/hexo-theme-next themes/next

3.2.2 user defined configuration file
Open username.github.io / _config.yml, and modify the following key value pairs (note that there must be a space after the colon):

title: GA-17's Blog
subtitle:
description: Hello World!
author: GA-17
language: zh-Hans
theme: next
deploy:
  type: git
  repo: https://github.com/wenjie710/wenjie710.github.io.git
  branch: master

3.2.3 configuration completed, write article!!!
Create your first blog under username.github.io/source/ posts. For example, create a file named firstblog.md in markdown format, and save it.

---
title: My First Blog
---

Our blog has been set up!!

3.2.4 release
Install the hexo deployer git auto deployment publishing tool

 npm install hexo-deployer-git --save

Publish blog

hexo clean && hexo g && hexo d

#Hexo clean clear cache
#Hexo g generates static pages
#Hexo s start service Preview
#Hexo d starts deployment

If this is the first time to log in, the terminal will let you enter GitHub’s email and password. After you enter it correctly, your blog will be uploaded to GitHub. In the future, you can execute this command after you write your blog.
At this point, the blog building is completed. Go to https://username.github.io to see your blog!!!

Recommended Today

Configure Apache to support PHP in the Apache main configuration file httpd.conf Include custom profile in

In Apache’s main configuration file / conf/ http.conf Add at the bottom Include “D:workspace_phpapache-php.conf” The file path can be any In D: workspace_ Create under PHP file apache- php.conf file Its specific content is [html] view plain copy PHP-Module setup LoadFile “D:/xampp/php/php5ts.dll” LoadModule php5_module “D:/xampp/php/php5apache2_2.dll” <FilesMatch “.php$”> SetHandler application/x-httpd-php </FilesMatch> <FilesMatch “.phps$”> SetHandler application/x-httpd-php-source </FilesMatch> […]