Hexo + Material + Github build blog and configuration

0. Prepare the environment

  • git
  • Node.js
  • Making account

1. Install

1.1 install git

Git download address

Next had nothing to say along the way

Verify this by executing it on the command line

1D:\GitRepository>git --version 2git version 2.13.2.windowsCopy the code

That means it worked

1.2 installation Node. Js

Node.js download address

Next had nothing to say along the way

Verify this by executing it on the command line

1D:\GitRepository>node -v 2v6.11.53 4D:\GitRepository> NPM -v 53.10.106Copy the code

1.3 installation Hexo

1npm install -g hexo-cli Copy the code

2. Create a local Blog

At the command line, enter an empty folder,

perform

1hexo initCopy the code

The local blog is created successfully

perform

1hexo g
2hexo sCopy the code

Visit http://localhost:4000/ to see your own blog.

3. Theme installation

The Viosey theme is used here

3.1 Download Topic:

1cd themes
2git clone https://github.com/viosey/hexo-theme-material.git materialCopy the code

3.2 Using themes:

Change the theme value of the _config.yml file in the home directory to the name of the git clone folder.

Rename _config.template.yml in the theme/material directory to _config.yml

3.3 Site search

Install the hexo-Generator-Search plug-in.

Change the search value in the theme/material directory _config.yml

1search:
2    use: local
3    swiftype_key: Copy the code

Then add it to the _config.yml file in the home directory

1search:
2    path: search.xml
3    field: allCopy the code

For other configurations, see the documentation

4. Submit the deployment

Create xxxx.github. IO repository on github where XXXX is your github user name

Install hexo deployer — git

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

Configure the _config.yml file in the home directory

1deploy: 2 type: git 3 repo: repository address 4 branch: masterCopy the code

Deployment to making

1hexo d -gCopy the code

Go to xxxx.github. IO /. Try (XXXX is your username)

5. Write a blog

Create a Blog template

1Hexo New This is my first postCopy the code

An MD file will be created in the source/_posts directory. You can edit this file to create a blog

6. Multiple machines

Sometimes you need to blog in a different place. This requires synchronizing the blog across multiple machines.

The idea is to create two branches, one for managing blogs and one for managing raw files

In the blog directory

6.1 Creating a Source Git Directory

1 the git init 2 git remote add origin / / https://github.com/xx/xx.github.io to fill in your 'addressCopy the code

6.2 Creating a Source Branch

1 git checkout -b source
2 git add .
3 git commit -m 'add source'
4 git push origin sourceCopy the code

6.3 Synchronizing Multiple Machines

Clone warehouse to local

Initialize Hexo. Do not repeat the steps above. Note the switch of branches

7 Categories & Labels

6.1 Creating a Category

perform

1 hexo new page categoriesCopy the code

Open source/categories/index, md

Is amended as:

1-- 2Title: Article classification 3Date: 2017-05-27 13:47:40 4type: "Categories" 5--Copy the code

6.2 Add categories to articles

1-- 2Layout: Hexo 3Title: Hexo + Material + Github Study Notes 8--Copy the code

Link to this article: zdran.com/20180326.ht…