Yangbo's Blog

Create a Github blog with Hexo on Ubuntu 16.04

This very first blog article introduces how to deploy Hexo with Github. For detailed information about Hexo, see the official document page.

Installing Nodejs

1
2
$ curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
$ sudo apt-get install -y nodejs

Installing npm and Hexo

1
2
$ sudo apt install npm
$ npm install -g hexo-cli

After the installation of Hexo, create a blog folder under the home directory.

1
2
3
4
$ hexo init blog
$ cd blog/
$ npm install
$ hexo -v

Check how the page looks like by running the command below and then open the generated link in a web browser.

1
$ hexo s --debug

Setting up Hexo themes

My preferred theme was downloaded from below:

1
2
$ cd ~/blog
$ git clone https://github.com/iissnan/hexo-theme-next themes/next

More settings about the NexT theme can be found here.

Configuring Github and Hexo

  • Create a new repository on Github and name it to be YangboLong.github.io
  • Generate a new SSH key:

    1
    $ ssh-keygen -t rsa -C "your_email@example.com"
  • Add the SSH key to your Github account: add key

  • Edit _config.yml in the directory of ~/blog
  • Run the following command:
    1
    $ sudo npm install hexo-deployer-git --save

Setting up deployment

1
2
3
$ hexo clean
$ hexo generate
$ hexo deploy

Now, my first blog is up and running. Enjoy!