0%

Hexo with GitHub Page

My original blog has been written with Octopress and then I migrated to Hexo. This post guides one to build up a blog with Hexo.

Prerequisite

Install

1
npm install hexo-cli -g

Usage

  1. Create Hexo blog

    1
    2
    3
    hexo init <folder>
    cd <folder>
    npm install
  2. Create a new page or post

    1
    2
    hexo new "<post>"
    hexo new page "<page>"
  3. Build up the blog

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    # Generate static files
    # hexo g
    hexo generate

    # Run the blog at http://localhost:4000
    # hexo s
    hexo server

    # Deploy blog on website (e.g. GitHub)
    # hexo d
    hexo deploy

    # Generate static files and run server
    hexo s -g

    # Generate static files and deploy
    hexo d -g
  4. Change the theme (e.g. NexT)

    1
    2
    3
    4
    5
    git clone https://github.com/theme-next/hexo-theme-next.git themes/next

    # Modify _config.yaml
    cat _config.yaml
    # theme: next
  5. Deploy to GitHub page

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    # Install plugin
    npm install hexo-deployer-git --save

    # Modify _config.yaml
    cat _config.yaml
    # deploy:
    # type: git
    # repo:
    # github: git@github.com:<username>/<username>.github.io.git

    # Deploy
    hexo d

My Configuration

Reference