0%

How to Set up your own website using GitHub and Hexo

How to Set up your own blog using GitHub and Hexo

What you should know before reading

  • Basic(and only basic) knowledge of Git and GitHub
  • You should have an account of GitHub
  • Basic(and only basic) knowledge of html
  • This tutorial is for Mac Users only. (I DON’T KNOW whether it can work in Windows/Linux.)

Creating a Repo in GitHub

  1. Create a Repo named <Your Account>.github.io
  2. Test it with a index.html with any text in it like Hello World
  3. Commit and push it to the remote branch.
  4. After a few seconds, you can visit the website
  5. Enjoy it!

Tips

If you are a Pro user of GitHub, you can set up your website using a Private repository, which means that others can only visit your website but not contents in this repository. But if not, you have to make it public.

Installing hexo

Before that, let us check …

If you haven’t installed Node.js

1
brew install node

Check if it succeeds

1
2
node -v
npm -v

Here we go!

1
npm install -g hexo-cli

Waiting a few minutes (or longer, depending on your network condition)

Check if hexo is successfuly installed

1
hexo -v

Initializing the Project

Creating Project

1
hexo init <blog-name>

Installing Independecies

1
2
cd <blog-name>
npm install

It’s nearly done…

Start a local servel

1
hexo server

Then view your page at this link and you will see it!

Page View

Connecting hexo with GitHub

Install hexo-deployer-git

1
npm install hexo-deployer-git --save

Edit Configuration File

Edit _config.yml like this

1
2
3
4
5
deploy:  
type: git
repo: <repository url> #https://bitbucket.org/JohnSmith/johnsmith.bitbucket.io
branch: [branch] #published
message: [message] #leave this blank

Deploy

1
hexo clean && hexo deploy

Then you can visit the website

Congratulations!