Use Hexo to build a personal blog and deploy to GitHub

1. Preparation

node.js download and install: https://nodejs.org/en/
git download and install: https://git-scm.com/


2. Start building a blog

2.1 Install cnpm

Use the npm package manager to install, but because the domestic mirror source is slow, first use npm to download cnpm, which is the source of Taobao, which is faster.

安装cnpm
npm install -g cnpm --registry=https://registry.npm.taobao.org

2.2 Build a blog

  • Use cnpm to install the hexo blog framework.
安装hexo博客框架
cnpm install -g hexo-cli
  • Check whether the installation is successful, enter hexo -v in cmd, if the following information is displayed, it means the installation is successful.
hexo -v

hexo-cli: 4.2.0
os: Windows_NT 10.0.19041 win32 x64
node: 12.18.4
v8: 7.8.279.23-node.39
uv: 1.38.0
zlib: 1.2.11
brotli: 1.0.7
ares: 1.16.0
modules: 72
nghttp2: 1.41.0
napi: 6
llhttp: 2.1.2
http_parser: 2.9.3
openssl: 1.1.1g
cldr: 37.0
icu: 67.1
tz: 2019c
unicode: 13.0
  • Create a folder, I named it blog here, open cmd to enter the folder directory, initialize the blog, and start, cmd will give a local access address, visit the address, you can see the blog just initialized.
初始化博客
hexo init
启动hexo博客
hexo s

2.3 Write a blog post

  • Create a new blog post in the blog/source/_post directory, and then go back to the blog directory to regenerate the blog
新建文章
hexo n "文章名称"
清理一下
hexo clean
生成
hexo g
本地启动
hexo s

3. Deploy the blog to GitHub

3.1 Create a blog repository on GitHub

  • Create a public warehouse on GitHub. The name of the warehouse is: your github name. github.io
    ps: the name in front of .github.io must be the same as your github name

3.2 Install the hexo-deployer-git deployment plugin

  • Install a deployment plugin in the blog directory
安装hexo-deployer-git
cnpm install --save hexo-deployer-git

3.3 Setting the _config.yml file

  • Find the Deployment configuration in this file (usually at the bottom). The first time you execute the deployment to the remote command, you will be asked to enter your account and password.
deploy:
  type: git
  repo: 仓库地址
  branch: master
部署到远端
hexo d

ps: Because it is a git tool, if it is the first time to use git, you must also configure git username and email

git config user.name "yourName"
git config user.email "yourEmail"

Information: Station B: "Teach you to build your own personal blog from 0 | No pit version video tutorial | hexo"-CodeSheep

Guess you like

Origin blog.csdn.net/qq_46402309/article/details/109149244