Install Hexo
- Install
Git
andNode
- Intall Hexo
$ npm install -g hexo-cli
Set up your blog files
Once Hexo is installed, run the following commands to initialize Hexo in the target <folder>
1 | $ hexo init <folder> |
Create a Repo on GitHub
Create a repo on GitHub with repo name as [your_github_username].github.io
.
Deploy
- Install deployer tool
npm install hexo-deployer-git --save
- Add the following configurations to _config.yml in the folder you created with
hexo init
just now.1
2
3
4deploy:
type: git
repo: https://github.com/<username>/<username.github.io>
branch: master - Run
hexo clean && hexo deploy
- Check the webpage at
username.github.io
Host your Source files
Note that if you follow the above steps to deploy your blog, the master
branch will only host the published files. There is another branch gh-pages
hosting your source files. You may want to host the source files with Pull Request approach. One way to do that is clone the repo<username.github.io>
to locale and copy the .git
folder to <my-blog-folder>
created by hexo init
, then checkout another branch (such as with name hexo-dev
) as the working branch and create PR to branch to gh-pages
branch if there is any change.