Building a Hexo Static Blog with GitHub!
Machine-translated (anthropic, claude-haiku-5-5) from the Chinese original. Read the original in 中文
Contents
Preface
First of all, we middle school students have final exams soon, and the older brothers and sisters are also about to take the college entrance exam (Gaokao). Congratulations to all the examinees in China:
May the moment you put the cap back on your pen be filled with the pride of a warrior sheathing his sword!
I believe you can do it
Put the best turning point on your life!
Main Text
Step 1
Install Node.js and configure the Node.js environment, then open the cmd command line. A successful setup looks like this:

Step 2
Install Git and configure the Git environment. The sign of a successful installation is that right-clicking anywhere on your computer shows the following two options:

Note:
For security reasons, Git operations are generally only available through Git Bash Here. If you need to call Git from the cmd command line, you have to configure the PATH environment variable, or select "Use Git from the Windows Command Prompt" during installation. It's up to you; the difference is not very significant. A successfully configured interface is shown in the figure:

Step 3
Register a GitHub account and create a new repository. The repository must follow the naming format: username.github.io, otherwise you will run into a lot of trouble later. Also, be sure to check "Initialize this repository with a README".

On the right side of the created repository there is a settings button. Click it and scroll down to GitHub Pages. You will see a URL there. Visit it, and you will be amazed to find that the repository has been deployed to the web and can be accessed from the outside network.

Step 4
Install Hexo. Create a folder in a location you think is suitable; I created a blog folder on drive D. Then use the command line to enter that folder.
If you don't know how to enter it, Baidu it yourself!

Enter
npm install hexo -gStart installing Hexo

Enter hexo -v to check whether Hexo was installed successfully

Enter hexo init to initialize the folder
It may take a little while, but it's only a little while, don't worry!


When you see "Start blogging with Hexo!" at the end, isn't it exciting!!!!!
Next, enter npm install to install the required components

Enter hexo s to start the server, visit the address, and officially experience Hexo

Problems:
If the page never loads, the port may be occupied. In that case, press ctrl+c to stop the server, then enter "hexo server -p port number" to change the port number

If the figure below appears, it has succeeded

Step 5
However, don't get too excited! You still need to upload to GitHub Pages
Let's set up your Git user name and email (if this is your first time)
For the upload settings and other details, please refer to my other article
[post cid="39" cover="https://cdn.xsiy.ltd/photo/github/github12.png]
Problems:
If SSH key configuration fails, the following steps will completely solve it
First, delete all key pairs
ssh-add -D
rm -r ~/.ssh
Delete the public key you added on GitHub
Regenerate the SSH key pair
ssh-keygen -t rsa -C "[email protected]"
Then proceed with the normal operations
Add the public key to GitHub:
-
First, run
xclip -sel c ~/.ssh/id_rsa.pubin your terminal to copy the contents of the public key to the clipboard -
When adding the public key on GitHub, just paste it directly!
-
Save
Step 6
Configure Deployment: in its folder, find the _config.yml file and modify the repo value (at the end)
The repo value is the SSH address of your GitHub repository. You all know this, so I won't say more!
Step 7
Create a new blog post by running the following command in cmd: hexo new post “博客名”
You will then see the newly created file in the _posts directory of the folder

Before generating and deploying the article, you need to install an extension:
npm install hexo-deployer-git --save
After writing the article in your editor, you can use the command hexo d -g to generate and deploy it

After a successful deployment, visit your address:
You will then see the generated article
Comments