Skip to content

Instantly share code, notes, and snippets.

Created May 26, 2016 09:41
Show Gist options
  • Save btfak/18938572f5df000ebe06fbd1872e4e39 to your computer and use it in GitHub Desktop.
Save btfak/18938572f5df000ebe06fbd1872e4e39 to your computer and use it in GitHub Desktop.
How to use Hexo and deploy to GitHub Pages

How to use Hexo and deploy to GitHub Pages

1. Install Hexo

$ sudo npm install -g hexo-cli

$ hexo -v
hexo-cli: 0.1.9
os: Darwin 14.3.0 darwin x64
http_parser: 2.3
node: 0.12.7
uv: 1.6.1
zlib: 1.2.8
modules: 14
openssl: 1.0.1p

2. Create a project for your GitHub Pages

$ hexo init
INFO  Copying data to ~/***/
INFO  You are almost done! Don't forget to run 'npm install' before you start blogging with Hexo!

$ cd

$ npm install

3. Run a test server for your page on Mac

$ hexo server
INFO  Hexo is running at Press Ctrl+C to stop.

4. Set information for your new blog

$ vi _config.yml

~~~~~~~~~~~~~~~~~~ _config.yml ~~~~~~~~~~~~~~~~~~
# Site
title: yt8yt's note
description: yt8yt's personal blog
author: yt8yt
timezone: Japan

## If your site is put in a subdirectory, set url as '' and root as '/child/'
root: /
permalink: :year/:month/:day/:title/

5. Set information to use Git

$ npm install hexo-deployer-git --save
$ vi _config.yml

~~~~~~~~~~~~~~~~~~ _config.yml ~~~~~~~~~~~~~~~~~~
# Deployment
## Docs:
  type: git
  branch: master

6. Set "watch" before starting your work

"watch" command can monitor your files.

$ hexo generate --watch

7. Create a new post file

$ hexo new first-post
INFO  Created: ~/***/

8. Edit the above file with Markdown or Hexo's Helper

Hexo's Helper
I use Atom with "shift + control + m" when I use Markdown :-)

9. Delete "source/_posts/"

It's not necessary to deploy.

10. Deploy your new blog!!

$ hexo clean
$ hexo deploy

After writting the above command, you can see your new blog on GitHub Pages.

11. Change your blog theme

For instance, How to use the following theme.

## Install it
$ cd
$ git clone git:// themes/light

## Update the above files
$ themes/light
$ git pull

## Set information to use the theme
$ cd
$ vi _config.yml

~~~~~~~~~~~~~~~~~~ _config.yml ~~~~~~~~~~~~~~~~~~
# Extensions
## Plugins:
## Themes:
theme: light

12. Create a new page file

$ hexo new page aboutme
INFO  Created: ~/***/

$ cd source/aboutme/

$ vi

13. Use "Read More"

Write <!-- more --> in your articles.

14. Use Plugins

Copy link

best hexo & github page tutorial

Copy link

This is so good! First time using Hexo and this made it so easy.

Copy link

KINGSABRI commented Aug 21, 2017

Install nodejs, nvm on ubuntu

Install required packages for nodejs

apt update
apt install build-essential libssl-dev
apt install nodejs
apt install npm

Install nvm

wget -qO- | bash 

Install latest stable nodejs version

nvm install stable

update your profile - to find nvm path

source ~/.profile

Install hexo

npm install -g hexo-cli


Copy link

thanks dude!

Copy link

Thanks, it's very useful!

Copy link


Copy link


Copy link

no ssh?

Copy link

fer commented Apr 10, 2018

Good stuff! Maybe worth to mention to add a CNAME under sources in order to use a custom domain.

Copy link

garyyu commented Apr 25, 2018

Nice and simple HowTo document~ Thanks!

Copy link

vi _config.yml not working. Says vi is not an internal or external command

Copy link

Thank you so much, buddy!

Copy link

Thank you. It's useful!

Copy link

ghost commented Aug 11, 2018

i changed my theme, my theme apply in local but i cannot reflect it to github page :((( even deploy many times

Copy link

thank's useful!

Copy link

Thank you! it's well explained!

Copy link

erlange commented Jul 8, 2019

This is the most concise and useful hexo tutorial. Thanks!

Copy link

This post is really helpful and awesome. Thank you for creating the piece.

Copy link

Thank you! Your post helps me a lot while I'm stuck with using Travis-CI.

Copy link

loyio commented Apr 28, 2020

thanks,great tutorial

Copy link

Thanks to share!! 🤙

Copy link

alifma commented Jul 8, 2023

Still works on July 2023, thanks mate!

Copy link


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment