0%

Modify Github Pages Rep for Hexo-Blog

Push a new branch

Create a new branch

Create a new branch like hexo in blog rep

Set the new branch as default branch in settings

Clone rep and modify

Under any local folder, clone the rep

1
git clone https://github.com/<Your username>/<Your username>.github.io.git

Under this local rep folder, delete all items exclude .git folder

Copy all items from the original blog file exclude .deploy_git folder. Check if there is a file called .gitignore and its content looks like:

1
2
3
4
5
6
7
.DS_Store
Thumbs.db
db.json
*.log
node_modules/
public/
.deploy*/

Meanwhile, focus on if there is any .git folder under your theme folders. Delete them all, or you will not have your themes config on your other devices.

Push to github

1
2
3
git add .
git commit –m "add branch"
git push

Push done.

You could check if all items exclude item in .gitignore exist in your github rep.

Setup on a new device

Setup git

Install git

1
sudo apt-get install git

Setup global config

1
2
git config --global user.name "yourgithubname"
git config --global user.email "yourgithubemail"

Install hexo

Install NodeJS

1
sudo apt-get install nodejs

Install npm, maybe already exist after installing nodejs
1
sudo apt-get install npm

Install hexo
1
sudo npm install hexo-cli -g

Clone rep and deploy

Under any folder, clone the rep

1
git clone https://github.com/<Your username>/<Your username>.github.io.git

Under the local rep folder

1
2
npm install
npm install hexo-deployer-git --save

Generate and deploy

1
hexo g -d

Then you could edit and deploy your blog as usual on this new device

Tips

  1. Commit and push src rep to github after editing
  2. Pull first on blog existed device before editing