Hexo introduction

  • https://hexo.io
  • https://hexo.io/zh-cn/

Environment to prepare

Install nodejs

  • Download: https://nodejs.org/en/
  • Take: node-v14.17.1.pkg as an example

Open the terminal and switch to root

For example, open the Terminal or Iterms terminal software and execute the following commands

// Switch to root user sudo su

Install Taobao mirror

/ / use NPM to install relevant dependent packages, speed is slow, suggest installation taobao mirror, subsequent command USES CNPM NPM install - g CNPM - registry=https://registry.npm.taobao.org

Install Hexo

// Install hexo CNPM -g hexo-cli

Hexo installed successfully

Initialize the blog site

Create a new project folder and enter it

For example: Blog. If there is a problem with the project later, or if you want to recreate it, just delete the folder

// Initialize the project (execute this command after you must be inside the project folder) sudo hexo init

Start the hexo

// Start hexo, hexo s

Browser opens the blog site

// Open your browser to http://localhost:4000

Create a blog and write a blog

  • The use of the Vim command can be referred to here

    // Create article hexo n "my first blog post" // Edit article vim my first blog post

Project Management Execution

Clean up the project cache

  • To add a blog post or modify the content of a blog post, you need to execute this command

    // Cleanup the previously generated site Hexo Clean

Regenerate the project

// Generate the blog project hexo g

Start the project again

// Start Hexo S again

Modify the theme

Choose a topic

You can download the theme according to your own needs. You can download it from the website for example: select Butterfly

Download the theme code

  • Execute the following command in the project root directory, under the “Blog “folder,

    / / clone theme code to themes/butterfly git clone https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly

Modify the project configuration file to configure the theme

// Modify the configuration file to the theme theme Vim_config.yml

In the project directory, execute the following command [very important, pro test valid]

This pit solution from here: https://zhuanlan.zhihu.com/p/…

npm install --save hexo-renderer-jade hexo-generator-feed hexo-generator-sitemap hexo-browsersync hexo-generator-archive

Regenerate the project

  • The specific operation process has been introduced in the previous chapter

    hexo clean
    hexo g
    hexo s

    Rerun the project



    New theme interface

Later, we can modify the theme interface and optimize the interface according to our own needs.

Deploy your blog to the cloud (GitHubYou need to have your own account.)

The new warehouse

Login: https://github.com Create a new repository. It must be a public repository.

The warehouse address where this case was successfully created:

https://github.com/CodingDGSun/CodingDGSun.github.io.git

Execute the following command under the project directory

cnpm install --save hexo-deployer-git

Modifying configuration files

// Modify the configuration vim _config.yml

Modify the last location of the file where [repo] fill in the newly created warehouse address.

type: git
repo: https://github.com/CodingDGSun/CodingDGSun.github.io.git
branch: master

Deploy the project to the cloud

// Execute the deployment command hexo d deployment

Visit the cloud blog home page

Access the address, the https:// warehouse +. The name of the new lot. IO such as this case is: https://CodingDGSun.github.io