How to dual open a blog?
The answer is to deploy a VPS with GitHub...
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, our blog will have faster access speed. Note that I chose not to initialize the repository at the beginning to 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"
Just press Enter three times, no need to set a password. 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, then paste the contents of id_rsa.pub
that was copied earlier, and 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~