1. Preparation

  1. Install Nodejs. Run the node -v command to check whether the installation is complete
  2. Install the NPM. Run the NPM -v command to check whether the installation is complete
  3. Install Git using git –version to check whether the installation is complete
  4. Set up a Github account (easy to remember and write, no special characters) and preferably have a scientific web tool, otherwise there will be a 404 risk in both installation and on Github
  5. Create a key and establish a link to Github

2. Start building

2.1. Register with Github and create the repository

The registered repository name is a bit special, it must have the name of your github account, such as

You can create an empty repository without selecting anything.

2.2. Create a blog using Hexo

The Hexo Chinese website can be downloaded to see the Hexo documentation

  1. Create an empty folder, such as blog, and enter the blog folder with the generated source code for hexo
  2. Use commands to install hexo globallynpm i hexo-cli -g
  3. Initialize hexohexo init npm install
  4. Create a blog locallyHexo new "Blog name"(Create blog)hexo g(Web page generation)
  5. View Hexo s locally (open server)

2.3. Deploy to Github

Go to the _config.yml file under the directory, slide to the bottom, modify the parameters in it, and create whatever you don’t have

The second repo is set to an SSH address. I’ve read a lot of tutorials that say HTTPS, but if SSH works, try HTTPS again

At this point, the default branch is still main, but I added hexo later

At this point you can deploy the project with Hexo, and the end result is to upload the compiled file to Github and put it on github Pagas like a server for everyone to access

The command is as follows:

  1. hexo clean(This command is needed to clear cached files, such as changing themes)
  2. hexo g(Generate static file)
  3. hexo d(Posted to Github)
  4. ingithub settingYou can find access paths in Pages

3. Synchronize blog updates across devices

The blog set up above can only write blog on the local machine set up. I had to change my computer, rebuild my environment, and rewrite my blog. Or blog backup, transfer and then write, very troublesome.

The main branch holds the compiled code for display. Hexo saves the source code for easy switching between devices.

After performing hexo d, we usually synchronize public files to Github, so we put public files in the Main branch and hexo website files in the Hexo branch

You can directly create a Hexo branch locally and push it remotely. And set hexo as the default branch so that git push code goes directly to the hexo branch later

Git add git commit -m “… Git push submits files related to your website

Execute hexo G-d to generate the site and deploy it to gitHub

4. Refer to the article

  1. zhuanlan.zhihu.com/p/370635512

  2. www.zhihu.com/question/21…

  3. Formulahendry. Making. IO / 2016/12/04 /…