Notes of Building Hexo Blog

Notes of building https://airt.github.io/notes/

Prerequisites

Initialize

Hexo documentation

1
2
npm install hexo-cli -g
hexo init notes

Configure

Hexo configuration

Modify url configuration in _config.yml:

1
2
3
# URL
url: https://yourname.github.io/notes
root: /notes/

Install a Theme

NexT for Hexo NexT documentation

1
2
version='v5.1.2'
git clone --branch $version --depth 1 https://github.com/iissnan/hexo-theme-next themes/next

Set theme in hexo root configuration _config.yml:

1
theme: next

More Themes

Install Plugins

Setup GitHub Repository

Creat a New Repository

New repository https://github.com/yourname/notes

Configure GitHub Pages

At https://github.com/yourname/notes/settings > GitHub Pages , choose gh-pages branch

Setup Continuous Deployment

Enable Travis-CI for Repository

Configure Travis-CI Scripts

Add script commands in .travis.yml:

1
2
script:
- npm run build

where npm scripts:

1
2
3
4
5
{
"scripts": {
"build": "hexo generate"
}
}

Setup Travis-CI Deployment for GitHub Pages

Add environment variables GITHUB_TOKEN in Travis-CI settings

And add deployment configuration in .travis.yml:

1
2
3
4
5
6
7
8
deploy:
provider: pages
skip_cleanup: true
github_token: $GITHUB_TOKEN
target_branch: gh-pages
local_dir: public
on:
branch: master

Publish

1
2
3
4
git add .
git commit
git push
open https://yourname.github.io/notes

Remarks

Hexo Commands

Hexo commands

Start a local server:

1
2
hexo server
open http://localhost:4000/

Examples

Source of this site: https://github.com/airt/notes