Setup-Github-Page-with-Hexo
Environments:
- Windows 10 64-bit
- git 2.28.0.windows.1
- Node.js v16.14.2
- npm 8.5.0
Prepare
Github
Register Github account and Create a new repository
- Goto the Github page and register your account.
- Click the
New
button in the webpage left side.
-
Input data.
-
Enter
Repository name
. You need to replaceusername
with your username.You can see your username in the upper right corner.
-
Check
Add a README file
[Optional] -
Click
Create repository
-
SSH Key
-
Right-click anywhere and click
Git Bash Here
. -
Enter
ssh-keygen -t ras -C EmailAddress
(replaceEmailAdress
with your email adress).After, use the default settings (press Enter) as shown in the following image.
-
Enter
cat ~/.ssh/id_rsa.pub
. Copy the string of text that is displayed. -
Goto the SSH key setting on Github.
-
Click
New SSH key
. -
Input
Title
(custom) and paste theKey
that you just copied. -
Finally, you’re done setting up Github.
Hexo
-
Everything is entered in
Git Bash
. -
You can also check out the documentation on Hexo.
Install Hexo
1 | npm install hexo-cli -g |
Setup your blog
1 | hexo init GithubBlog |
You can find the GithubBlog
folder.
1 | # Folder structure. |
Create a new post
1 | hexo new post "new post" |
Local Server
1 | hexo s |
Open your browser and type http://localhost:4000/
.
Deploy to Github
-
Install a deployment plugin.
1
npm install hexo-deployer-git --save
-
Goto the
GithubBlog
folder, open the_cofig.yml
file, locate thedeploy
and enter the following1
2
3
4deploy:
type: git
repo: [email protected]:username/username.github.io.git
branch: masterSSH link entered in the
repo
can be retrieved from the repository, as shown below -
Generate & Deploy
1
2
3hexo g
hexo d -m "First"
# -m "" You can enter a description of the content of this update -
In Github repository.
-
Finally, type in your browser:
username.github.io
.
Find theme (Optional)
You can find your favorite theme on themes that will make your Blog look better.
The theme I’m using is Butterfly.
For details, please refer to the theme documentation.