How to install Hexo on Github and write a first blog post

How to install Hexo on Github

Hexo is a static website generator. You can use Hexo as a Github blog.
In this post, I’ll let you know how to install Hexo on Github.

Keep the node and npm version up to date before installing Hexo.

  • Check node version

    1
    $ node -v
  • Check npm version

    1
    $ npm -v
  • If node and npm is not latest version, please install latest version of node @ nodejs.org

Hexo installation

  • Install hexo-cli using npm gloabally

    1
    $ npm install -g hexo-cli
  • (FYI) Check global npm packages installation location

    1
    $ npm root -g
  • (FYI) global npm packages intallation location

    1
    C:/Users/user/AppData/Roaming/npm/node_modules
  • Create Hexo files inside blog folder

    1
    $ hexo init blog

Github repository and Hexo Deploy Setting

  • Create the github respository

    1
    [github-username].github.io
  • Set the github repository.
    Modify the _config.yml file as below.

    1
    2
    3
    deploy:
    type: git
    repo: https://github.com/[github-username]/[github-username].github.io.git

Hexo Setting

  • If you want to create asset folder for each blog post, please update the _config.yml file below:
    1
    post_asset_folder: true

Write a first hexo blog post

  • Create a draft

    1
    $ hexo new draft [title]
  • Create a Thumbnail Image

    1
    width * height = 520*245
  • Set thumbnail for blog post
    create images folder inside source folder then set the path as blow

    1
    thumbnail: ../images/image.png
  • Insert the image on blog post
    If you have an asset folder for each blog post.

    1
    ![](image.png)
  • Preview draft

    1
    $ hexo server --draft
  • Publish draft

    1
    $ hexo publish
  • Preview publish

    1
    $ hexo server

Publish Blog Post

  • publish blog post

    1
    $ hexo publish [title]
  • Create static files before deploy

    1
    $ hexo generate
  • Deploy the static files on Github

    1
    $ hexo deploy
Share