to build your blog on github
# Build Blog with Hexo and GitHub Pages
# Published: 2022/08/26
# Updated: 2022/08/26
# PREFACE
# As my very first blog, here I want to record some point and hope that it will help whoever wants to build his own blog.
# THE THINGS NEED TO BE DONE
hexo
Hexo is a blog framework based on Node.js. We can maintain a Hexo instance on local machine, and publish it to Github pages.
node.js
an free open source server environment which can be ran on Windows, Linux, Unix, Mac OS X, ect.
set up the github account
GitHub Pages is a static site hosting service designed to host your personal, organization or project pages directly from a GitHub repository
# Node.js
Go to Download - Node.js, choose and install the right version for your computer.
Run node -v
then npm -v
on cmd, check your Node.js version if it doesn’t output two version of node and npm.
# git
Go to Download - git, leave the options default if you don’t understand.
When you are done, use cmd to chack if you do it right by run
git --version
If it outputs your git version, you do it right.
run
git config --global user.name "Your Name"
git config --global user.email youremail@example.com
ssh-keygen -t rsa -C "youremail@example.com"
and you will get two files(your own screen name and your email)
# Hexo
Run npm install hexo-cli -g
on a folder you would like to
Run hexo init
and npm install
on THE FOLDER YOU WANT TO PUT YOUR BLOG IN, run hexo version
( hexo -v
) to verify Hexo.
run hexo g
then hexo s
(hexo server)
and visit your blog (http://localhost:4000, the default port is 4000, if it reports error, try to run hexo s -i
, i stands for the port that isn’t occupied)
find _config.yml
, find deploy:
,part and edit:
deploy:
type: git
repo: git@github.com:yourname/yourname.github.io.git
branch: master
Create a GitHub Repository
# TIPS:
Change your GitHub Branch from “main” to “Master”
Find a file end with “id_rsa.pub” which generated when you install git and get the ssh key above. Copy it and paste it into your GitHub Repository ssh key
run npm install hexo-deployer-git --save
Now, run hexo d -g
and visit your GitHub wesite (which you can find in your repository SETTING), you should see your blog above.