Preparatory work

Install git

Download the version suitable for your system from the official website

This article will not elaborate on Git installation methods, you can follow the tutorial of Cainiao or Liao Xuefeng for installation.

Installation node. Js

fromwebsiteDownload Choose to download long term supported versions! Two tools, Node and NPM, will be installed after the download and installation. Press Win +R and type Powershell to verify the download is successful

node -v
npm -v
Copy the code

The output result is as follows:

Install CNPM

Due to the slow download speed of NPM, the domestic mirror CNPM needs to be installed, and the warehouse is Taobao warehouse

npm install -g cnpm --registry=https://registry.npm.taobao.org
Copy the code

After the installation is complete, enter

cnpm -v
Copy the code

Verify that the installation is successful

Install Hexo

Hexo initialization

Create a folder on your local computer to store your blog content

D:\00 DATA\08 HEXO blog\blog 
Copy the code

Go to the current folder in Powershell and type the code to install Hexo

cnpm install -g hexo-cli
Copy the code

After the installation is complete, the following information is displayed:

The input

hexo -v 
Copy the code

Check whether hexo is installed successfully. The installation is successful as shown in the figure above

Hexo initialization and local preview

After the Hexo installation is complete, you need to implement the Hexo initialization and generate the sample blog. Type in the blog folder

hexo init
Copy the code

If the host is not changed, github downloads slowly. Wait about 2 minutes. If no error message is displayed, github is successfully installed. Enter the command after the installation is successful

hexo s
Copy the code

You can preview it at http://localhost:4000.

Hexo creates a new blog

After completing the above initialization, you can create your first article. Enter the command:

"My first Hexo blog"Copy the code

The content in the double quotes is the blog name, which is stored in

.\source_posts

See where your blog is saved

There is a generated.md file, edit the.md file using Markdown, save it (the editing method of the.md file is not detailed here, you can use Typora tool, vim, etc.), and enter three commands in the blog folder

hexo clean
hexo g
hexo s
Copy the code

Can be found inhttp://localhost:4000Port View the generated result.

Deployed toGitHub

Set up a Git repository and install Git plug-ins

Github. IO: Create a repository in your github account and enter the following command:

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

The following message is displayed if the installation is successful:

Setting the configuration file

To deploy to remote github, modify the _config.yml file in the hexo file and open the file to locate the deploy location

Modify the type attribute (type) to add two attributesRepo and branchThe repo attribute corresponds to the Git address, and branch corresponds to the branch option.

Remote deployment

After modifying the _config.yml file, you need to deploy the local blog to Github and run the command

hexo d
Copy the code

Wait for the login page to appear, enter the account password:

Deployment is complete

Subject to beautify

Subject to download

The theme of Hexo is Landspace, and the theme style can be changed. Download the Yilia theme here. Enter the command in the blog folder:

git colne https://github.com/litten/hexo-theme-yilia .\theme\yilia
Copy the code

The url is the download address, and the path after the url is the storage location of the theme. Download complete as follows:

Go to the Theme folder and check whether the theme is saved:

Change the topic

After downloading, modify the _config.yml file in the blog folder to find the theme property

If the theme has not been changed, it will be displayed as theme:landspace, and landspace is the theme name. Change it to theme:yilia, and enter three lines in the window to view the modification locally:

hexo clean
hexo g
hexo s
Copy the code

If nothing goes wrong, you can push it to Github and type:

hexo d
Copy the code

Note: It is recommended to try fluid theme previews on the developer’s own blog

Problems encountered

Encountered some minor problems during hexo initialization, entered the initialization instructionhexo init, the error result is as follows:

Enter as promptednpm installIs still an error

Considering that it may be caused by failure to connect to the server, I choose to input the commandcnpm installProblem solving