The main steps are as follows:
-
Download node.js
- hexo blog is a static blog based on node.js, so node.js must be installed. It is worth mentioning that when installing node.js, npm will be installed by default. The full name of npm is Node Package Manager, which is used to manage (install or uninstall) related packages of node.js, which greatly simplifies our operation of packages, so we will use npm to install hexo later.
- Node.js is installed all the way to next, the default option is sufficient. After the installation is complete, open cmd, enter
node -v
, if the version number is displayed, the installation is successful
-
Use npm to install hexo
- Because of the existence of npm, our installation of hexo is very simple. Just enter the
npm i -g hexo-cli
command to complete the installation of hexo. However, due to domestic network speed limitations, PlanB can be used if the installation is unsuccessful. - PlanB: Use Taobao's domestic mirror source curve to save the country, install cnpm first, and the cmd command is
npm i -g cnpm --registry=https://registry.npm.taobao.org
. Then use cnpm to install hexo, the command is similar to npmcnpm -i -g hexo-cli
(it is recommended to install the official recommended hexo-cli instead of hexo) - Can be used
hexo -v
to determine whether the installation was successful
- Because of the existence of npm, our installation of hexo is very simple. Just enter the
-
Create a blog with hexo
-
First create a folder to store future blogs. Then
cd
enter the folder and use thehexo init
command to initialize. If everything goes well, you will be prompted: the
directory structure should be like this:
and enter thehexo s
start service, after completion, the browser visits http: // localhost: 4000, you can see the home page generated by hexo. The four commands on the homepage will be used frequently in the subsequent blog creation, and the meanings they represent are as follows:hexo new "My New Post" // 创建博客,可简写为 hexo n hexo server // 启动本地服务,可简写为 hexo s hexo generate //生成静态文件,可简写为 hexo g hexo depoly //部署到远端,可简写为 hexo d
-
Next, write a blog in actual combat, first
hexo n
create a blog with commands (here a markdown file is created): the
created blog is stored at the address/ source / _posts /
and then you can use the vim command or other ways to edit the blog (I use the Typora editor here, mainly to see at the results)
after editing, usehexo clean
to clear db.json cache (not necessarily, if the site shows abnormalities, try using), thenhexo g
generate static file, and finally start the servicehexo s
, enter the URL access, you can see just write blog friends .
-
-
Push to github
- First of all, we need to have a github account, and configure the SSH key , and then we can create a new warehouse . Note that the warehouse name must be
username.github.io
, this warehouse name is the url address of the future visit blog. - Next, we need to push the local blog to github, so we need to configure the "_config.yml" file after init. This file is very important. After that, we need to use this configuration file to modify the theme and add pictures to the blog. We find the Deployment and modify it to the following figure: repo is our warehouse address. Note that there is a space after the colon.
- Also you need to download a plug-in deployment:
cnpm install hexo-deployer-git --save
. After installation, ithexo d
can be deployed to github as long as it is used . In the middle, we may need to enter the github username and password. - If all goes well, enter the warehouse address in the browser
username.github.io
to see our blog deployed on github.
- First of all, we need to have a github account, and configure the SSH key , and then we can create a new warehouse . Note that the warehouse name must be
tips:
In this process, it is inevitable that it will fail due to factors such as network speed. If there is a problem, just delete the newly created blog folder and try again, because all our operations are performed in this folder, so it is a big deal.
Of course, if you are successful, you can also try to change your favorite blog theme. I recommend themes with more stars on github , such as next and yilia . I use the next theme myself, which is very concise and atmospheric.
Let's choose a good-looking theme and let's blog together ~