The project is hosted on Gitee and is recommended to be hosted on Gitee.

1. Installation Node. Js

Click here to download the LTS version.

The installation

2. Open the terminal

Run the sudo su command to obtain administrator rights

View the current directory: PWD

Check the node version: node -v

View the NPM version: NPM -v

If the version is displayed, the installation is successful.

3. Install taobao’S CNPM manager (to speed up the download)

npm install -g cnpm --registry=http://registry.npm.taobao.org

View the CNPM version: CNPM -v

4. Install the Hexo framework

cnpm install -g hexo-cli

View the hexo version: hexo-v

5. Create the Blog folder

Example: mine was created under projects.

mkdir projects/blog/

6. Go to the blog directory

Example: mine was created under projects.

cd projects/blog/


All of the following commands operate under the blog folder

7. Generate the blog (initialize the blog)

sudo hexo init

Start Blogging with Hexo! The command is successfully generated.

8. Start a local blog service

hexo s

Enter localhost:4000 in the browser address bar

You can see the blog generated locally.

Return to terminal and press CTRL + C to exit the local blog service.

9. Install the Git deployment plug-in

cnpm install --save hexo-deployer-git

Fatal: index-pack failed

10. Download the Yilia theme

This article uses Yilia as the theme and is recommended for beginners. Can also begithubFind your favorite theme to download.

git clone https://github.com/litten/hexo-theme-yilia.git themes/yilia

It may be slow to download using commands, so go to Github and download it (click here), unzip it, name it yilia, and put it under blog/themes/.

11. Build a new warehouse on Gitee

Click here and click on the plus sign in the upper right corner ->New Repository

Fill in Name and Path as Owner (your nickname)

(Please refer to the help documentation for the name.)

New

A Settings page is displayed, please copy HTTPS… Git’s address.

12. Modify the _config.yml configuration file

Modify _config.yml under blog

The file is full of key-value pairs, values must be preceded by Spaces.

This can be changed by command:

Open with vim: vim _config.yml

To the bottom of the file: :$

To the top of the file: :1

Enter INSERT mode: I

Exit INSERT mode: ESC

Save the configuration and exit: :wq

There are three modifications and one addition. Please replace the following parentheses and the words in parentheses.

Domain address: https://(your nickname).gizee.io /

Git address: https://gitee.com/(your nickname)/(your nickname).git

# modified url configuration url: (this is your domain name address, example: https://xuanmichael.gitee.io/).Copy the code
# Modify theme configuration: Theme: yiliaCopy the code
# modified deployment configuration to deploy: type: git repo: (this is your git address, example: https://gitee.com/xuanmichael/xuanmichael.git) branch: masterCopy the code
JsonContent: Meta: false pages: false posts: title: true date: true path: true text: false raw: false content: false slug: false updated: false comments: false link: false permalink: false excerpt: false categories: false tags: trueCopy the code

13. Deploy it on the server

Clean: Hexo Clean

Generated: hexo g

Deployment: Hexo D

If Deploy Done: git is displayed, the deployment is successful.

Go back to your Settings page and it will become the repository page for your project.

The default is Code, please find Service, go to Gitee Pages.

If you click Create and wait for a while, Gitee Pages service is open, URL: (This is your domain address, my address is: XuanMichael.githee.io)

Click on the domain name and enter the blog you set up.

14. Solve missing modules (skip this step for non-Yilia themes)

When you click on all articles on the left, the word “missing module” appears.

Return to the terminal and execute the following command:

npm i hexo-generator-json-content --save

hexo clean

hexo g

hexo d

Deployer not found: git

You need to install the git deployment plug-in again: CNPM install –save hexo-deployer-git

hexo d

Go back to Gitee Pages Services and click Update

Check blogs

Enter your domain name in the browser address bar to go, my is: https://xuanmichael.gitee.io/


At this point, a static blog built with Hexo is complete.

To build on these themes/yilia/**, change _config.yml

For details, see the configuration here.

Pay attention to

To Update anything in the blog, re-execute hexo’s three commands and go to Gitee Pages Services and click Update

To Stop the service, click Stop

To Clear the repository, Settings->Clear->Clear Repository

To Delete the repository, Settings->Delete->Delete Repository

The server may not immediately update, what non-server big problem, you can delete the blog folder to rebuild the blog.

It is recommended that the browser clear the cache and hard refresh after each major update (image upload, layout change, etc.).

Common operations (under the Blog folder)

New article (all articles are in.md format) : hexo n “Article name”

You can also create a new one under blog/source/_posts/, but command creation is recommended.

**blog/source/_posts/ **

Clean: Hexo Clean

Local preview: Hexo S

Generated: hexo g

Deployment: Hexo D

How to write a Markdown article?

After creating a new post with the command, go to blog/source/_posts/ and find the new post.

It is recommended to open it with Typora and modify it with Vscode.

I want to modify hello. Md’s article:

The default configuration is:

title: hello
date: 2020-08-16 00:11:28
tags:
Copy the code

Title is the title.

Date is the creation time of the file.

Tags are tags:

Tags: testingCopy the code

After the modification, save the modification.

Click the Retry as Sudo button in the lower right corner

Enter your password.

The file is saved successfully.

hexo g

hexo d

Go to Gitee Pages Services and Update.