1. Preparation
- Install Nodejs. Run the node -v command to check whether the installation is complete
- Install the NPM. Run the NPM -v command to check whether the installation is complete
- Install Git using git –version to check whether the installation is complete
- 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
- 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
- Create an empty folder, such as blog, and enter the blog folder with the generated source code for hexo
- Use commands to install hexo globally
npm i hexo-cli -g
- Initialize hexo
hexo init
npm install
- Create a blog locally
Hexo new "Blog name"
(Create blog)hexo g
(Web page generation) - 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:
hexo clean
(This command is needed to clear cached files, such as changing themes)hexo g
(Generate static file)hexo d
(Posted to Github)- in
github setting
You 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
-
zhuanlan.zhihu.com/p/370635512
-
www.zhihu.com/question/21…
-
Formulahendry. Making. IO / 2016/12/04 /…