[hexo series] 01. Hexo environment construction and github.io construction

Basic environmental requirements

To check whether Node.js is installed successfully, enter node -v on the command line
to check whether npm is installed successfully, enter npm -v on the command line
because I have installed it before

install hexo

# 安装
npm install -g hexo-cli
# 安装之后验证
hexo --version

first experience with hexo

My note root directory is E:\SynologyDrive

Create a hexo project

Method 1: Operate in the root directory

hexo init blog

You can see that a folder called blog has been generated

Method 2: Create a new blog folder (change it to your own name)

Go to the blog folder and execute:

hexo init

The effects of these two are the same. After execution, you will see that the things on git are pulled under the blog folder, as follows:

First Experience

source/_posts post folder

Open the folder, you can see that there is a document called hello-world.md below

Start the hexo server:

hexo server

Visit this URL in your browser:

You can see the above page~

Create your first note

implement:

# 新建一篇文章
hexo new "first"

You can see the newly created file under the source/_posts folder

Add some content to your notes and see

echo "first article" >> first.md
cat .\first.md

Execute in the blog root directory:

# 生成静态网页
hexo generate

Start the hexo server: (If the server has been running just now, this step is unnecessary)

hexo server

Access the server URL in the browser:

You can see the article you just created, and the first note is ready~

Push to the github website

Create a new github.io

push to github

The above operation is to start the hexo server locally. The essence is to browse locally. We can choose to push the blog to github.

npm install hexo-deployer-git --save

Modify the _config.yml file in the blog root directory

Open the file, before modification:

After modification: (add content below deploy)

In fact, it is to configure the hexo deploy command to let hexo know where you want to deploy the blog. Obviously, we deploy it in our GitHub warehouse.

implement:

hexo clean
hexo deploy

Hexo deploy needs to enter the user name and password, and it reports an error after entering it many times. Later, I learned from the information that the password can be entered into the github token (important) .

Where to get the token:


I use the classic, have not used another one.

After entering the token, you can upload it. as follows:

After uploading, you can see so many files on github:

Visit ningan123.github.io:
(If there is nothing to visit at the beginning, it is recommended to wait for a while, and there will be a while)

Successfully pushed to github~

Push to github (password free in ssh mode)

Add a new line of documents to distinguish it from the last time

echo "hexo deploy git ssh" >> .\first.md

Modify the _config.yml file in the blog root directory

implement:

hexo clean
hexo deploy

(Because I have already configured the ssh key on github before, if you haven't configured it yet, just search it online)

As you can see, there is no need to enter the user name and password for this push~

It has also been updated on github~

References

# GitHub Pages + Hexo to build a personal blog site, the most complete tutorial in history

Guess you like

Origin blog.csdn.net/weixin_42072280/article/details/128277772