Setting up a Github Pages blog with Hexo
Setup
You'll need the following installed before you can pop the champagne:
- Node.js
- Hexo
npm install -g hexo
Setup Hexo
Once you've got Hexo installed, you can simply run:
1 2 | $ hexo init username.github.com $ cd username.github.com |
Next, we need to configure a couple of things so open up the config file:
1 | $ vim _config.yml |
Some items you'll want to immediately change are:
- Title
- Subtitle
- Url
- Author
To make Github deployments work with hexo deploy
you'll want to make sure
that the # Deployment
section looks something like:
1 2 3 4 | deploy: type: github repository: https://github.com/username/username.github.com.git branch: master |
Setup Github
Github provides hosting for static websites via Github Pages. As long as you have an index.html in the root of your repo, Github will serve up the static files for you.
Create a new repository for your blog
You can get this setup by creating the required repository for your new blog,
simply create a new repo
with the name format as <github username>.github.com
, for example: jdpaton.github.com
.
Once the repo has been created you can setup the deployment process in hexo with:
1 | $ hexo setup_deploy |
Generate some content
Now that everything is assembled in place, it's time to flesh out the blog. To generate a new post in Hexo simply issue:
1 | $ hexo add_post <title> |
That command will create a new post in source/_posts/<title>.md
.
More info about article structure here
Now you can go ahead and add your content, and then when finished, simply run:
1 2 | $ hexo generate $ hexo deploy |
And your new blog will be live at http://username.github.com
Hexo: Docs
Here's one I made earlier ;)