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 a Hexo blog and then deployed it to GitHub.
Create a remote repository#
Create a repository on GitHub with the name "username.github.io". This repository can generate a blog at "username.github.io" after automated deployment. By using GitHub's powerful CDN outside of mainland China (mainland China is an isolated island on the Internet), our blog will have faster access speed. Note that I initially chose not to initialize the repository to avoid some inexplicable pitfalls!
Modify site configuration#
In the root directory of the site, find the keyword "deploy" in _config.yml
and modify the entire section to:
deploy:
type: git
repo: The complete path of the repository on GitHub, including .git
branch: master
The link of the repo 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 Building Personal Website Detailed Tutorial
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™!
Celebration~