How to dual open a blog?
The answer is to deploy a VPS and GitHub together...
Well, I admit that I used a clickbait title. The main purpose is to record how I successfully deployed my Hexo blog and then how to deploy it on GitHub.
Create a remote repository#
Create a repository on GitHub with the name "username.github.io". This repository can automatically generate a blog at "username.github.io" after automated deployment. By using GitHub's powerful CDN outside of mainland China (mainland China is like an isolated island on the Internet), our blog will have faster access speed. Note that I initially chose not to initialize the repository, which can avoid some inexplicable pitfalls!
Modify site configuration#
In the root directory of the site, find the _config.yml
file and look for the keyword deploy
. Modify the entire section to:
deploy:
type: git
repo: The complete path of the repository on GitHub, including .git
branch: master
The link in the repo
field must be ssh, not https!!!
Configure git#
Generate SSH keys
git config --global user.name "Your GitHub username"
git config --global user.email "Your GitHub registered email"
Generate SSH key file:
ssh-keygen -t rsa -C "Your GitHub registered email"
Then just press Enter three times, no need to set a password by default.
Then find the id_rsa.pub
key in the generated .ssh
folder and copy all its contents.
Open the GitHub_Settings_keys page and create a new SSH Key
.
The Title
can be any title, and paste the copied id_rsa.pub
content into it. Finally, click Add SSH key
.
Success!
The above content is from GitHub+Hexo Detailed Tutorial for Building Personal Websites
Push the blog to GitHub
Okay, we can use the following command to push the blog to GitHub and achieve a certain level of neveroffline™!
Celebrate~