Build a personal blog based on Hexo and GitHub

Foreword
After the process of building my blog, I have benefited a lot. The following records the process of my construction, and record some problems encountered during the construction. (There are many problems encountered during this period, so you must be patient.)

Preparation before building

1. Download and install Git *
Git download address
(the download process is very slow, very very slow, and there may even be an error after downloading and re-downloading)
basically all the way next, according to the default, but this step is an exception

Insert picture description here
In addition, the administrator interface can view the input. git
If the following situations occur Insert picture description here
, enter set PATH=%PATH%;E:\Git\bin (personal installation path) and add environment variables.
Insert picture description here

2. Download and install node.js
node.js download address The
default is all the way, but the installation path can be changed as needed
3. Install hexo,
open Git Bash, enter the command and npm install -g hexopress Enter . After typing
, there may be no response, so be patient. If there is no answer for a long time, you can also repeat this operation.
Then you can enter to hexo versioncheck whether the installation is successful.
If you can see the version information, you can install it successfully.
Insert picture description here
Put some simple commands
here hexo init
#initial hexo n "My Blog" == hexo new "My Blog" #New article
hexo p == hexo publish
hexo g == hexo generate#generate
hexo s == hexo server #start service preview
hexo d == hexo deploy#deploy
hexo server #Hexo will monitor file changes and update automatically, you don’t need to restart the server.
hexo server -s
#Static mode hexo server -p 5000
#Change port hexo server -i 192.168.1.1
#Custom IP hexo clean #Clear cached webpage under normal circumstances, this command can be ignored
hexo g #generate static webpage
hexo d #start deploy

GitHub preparation

1. I won’t talk about GitHub registration.
After logging in, click new repository, and fill in your own name + .github.io
for Repository name. For example, if you start a ### name, your Repository name should be ###.gthub.io
2 .Configure the GitHub ssh key.
First, right-click on the blank space on the desktop and select Git Bash Here

ssh-keygen -t rsa -C "your's emaill address

Enter your email address in the quotation marks, then press Enter, you will be prompted to save the file path, then press Enter to confirm
and then you will be prompted to enter the password, just enter it (you can’t see the password if you enter it), and then After confirming the input once, you can see in the path just now that two files have been generated, one is id_rsa and the other is id_rsa.pub. Open id_rsa.pub with notepadd++ and select all the contents and copy them.

Log in to github, click on the avatar to see the setting option, click to enter,
and then you can see an SSH and GPG keys option on the left.
Click to see the following interface, click New SSH
Insert picture description here

Create a local repository and synchronize with GitHub

Create a folder locally, right click git bash here and
enter the following command

git init
git config --global user.name "Your's name"
git config --global user.email "Your's email address"
git add README.md
git commit -m "first commit"
git remote add origin [email protected]:yourname/yourname.github.io.git
git push -u origin master

After entering github, you should be able to see the README.md file just submitted under the pants.

Configure Hexo to GitHub

Find the folder we just created, find the _config.yml file in it, open it with notepad++, drag it directly to the end, you can see

deploy:
  type:

Change to the following

deploy:  
  type: git
  repository: http://github.com/yourname/yourname.github.io.git
  branch: main

Note that the branch behind the branch must be main, and it must not be changed to master. This place is stuck for one day and
save it.
Open Git Bash Here in the current folder and
enter

hexo g
 hexo d

If the following exception occurs

ERROR Deployer not found: git

Enter the following command
https://hexo.io/themes/

 npm install hexo-deployer-git --save

Repeat the above operations.
If a dialog box pops up, just enter your GitHub username and password. The
blog has been set up successfully since then

Switch theme

Configure in _config.yml

Read more topics here.
Enter commands
in the hexo root directory, git bash here

git clone https://github.com/iissnan/hexo-theme-nextthemes/next(next为主题名字)

Insert picture description here
Insert picture description here

Insert picture description here

Thereafter, the local reading
HEXO G
HEXO S
is then deployed to GitHub
HEXO G
HEXO D
to

How to post a blog

Find the posts folder and
create a new document, change the suffix to .md, open it, and write content.
Insert picture description here
In this folder, git bash here
hexo g
hexo d will
Insert picture description here
be published as follows.

Insert picture description here
Now my first blog is completed. Insert picture description here
Phew~~~~, since then, Xiaofeichai’s blog building journey has come to an end. During the period, I encountered a lot of problems, unavoidable eagerness and self-doubt, but the moment I made it, I felt that I became a light. .

Guess you like

Origin blog.csdn.net/qq_51954912/article/details/113383755