Install the prerequisite

Hexo is a Node.js-based blogging framework, so before you install Hexo, make sure you have the following ready:

  1. Installation of the Node. Js
  2. Git installed
  3. Set up a GitHub account

If you haven’t done that yet, follow these steps:

Installation Node. Js

  • Download the corresponding version from node. js’s official website
  • Once you’ve downloaded it, click Install and go next
  • Verify that the installation is successful win + R key, enter CMD to enter the command prompt, and then enter respectivelynode -vandnpm -vIf the corresponding version number is displayed, Node.js is successfully installed

Install Git

  • Download the corresponding version from Git’s official website

  • Once you’ve downloaded it, click Install and go next

  • After the installation is complete, open all programs. If you see the following program, the installation is successful

  • Configure git environment variables

On the desktop, right-click on my computer and select Properties > Advanced System Configuration > Environment Variables > System Variables. Select path and go to Edit > New. Find the git installation directory, add bin and Git-core, and save.

Set up a GitHub account

Enter theMaking website, click on thesign inJust register.

With these preparations in place, it’s time to set up your own blog.

Step 1: Install the Hexo framework

Open the command line terminal (CMD) and enter the following command:

npm install -g hexo-cli
Copy the code

After the installation, verify whether the installation is successful:

hexo -v
Copy the code

Step 2: Create a blog directory

Create a folder with any name under your favorite drive letter and directory to store your blog later. For example, my blog directory is D:\personal\blog

Warm tips: in the process of building a blog, may encounter a variety of problems and errors, nothing, do not lose heart, the biggest deletion of the blog folder, start again!

Step 3: Initialize the blog

From the command prompt, use the CD command to go to the root directory where you created the blog. For example, I still have the D:\personal\blog directory.

Then enter the following command:

hexo init
Copy the code

If the following information is displayed, the blog is successfully initialized.

prompt

After the blog is successfully initialized, the following files and directories are generated in the root directory of the blog:

Step 4: Start Hexo

Enter the following command at the root of hexo (blog) :

hexo s
Copy the code

The s in the hexo s command is the abbreviation for server. After entering the s command, you will be prompted with the address and port number of the blog to access the local blog.

To exit, press Ctrl + C.

Step 5: Deploy your blog to GitHub

  • Create a special repository on GitHub

Github. IO, where XXX is your github name.

Because this repository is the only one on GitHub that has direct access to static resources, it can be used as a server for static resources.

For example, my warehouse is as follows:

  • Install the Git deployed plug-in

Run the following command in the root directory of your blog:

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

After the installation is successful, the following screen is displayed:

  • Modify the configuration file in the root directory of the blog

Locate the _config.yml file in the root directory of the blog (site directory), locate the deploy: configuration, and configure the following:

  • Once configured, you can deploy to GitHub

The following are common commands:

hexo clean
Copy the code

Clearing the local cache

hexo g
Copy the code

Generate local static files

hexo s
Copy the code

Start the local blog server

hexo d

Copy the code

Deployment to making

conclusion

At this point, a basic blogging framework based on Hexo and GitHub is in place. If you are not satisfied with the theme style of your blog, you can do your own search, according to your personal preferences, with a full personality of the blog site. I hope this blog can help you and we will make progress together in the future!