Mar 6 2017

Setting up Hexo on Windows

Follow these instructions to install and configure the Hexo blog framework on Windows.

Requirements

Installing Node.js

  1. Install Node.js

    Node.js Windows Installer

  2. Make sure to allow Node.js Windows Firewall access.

    Windows Firewall access

  3. Verify the installation by running the following commands inside the Git Bash:

    1
    2
    node -v
    npm -v

Re-installing hexo

For those re-installing Hexo and using an existing hexo blog repository:

  • do NOT create the directory described step 1 but checkout your blog repo instead
  • cd into your repo directory and git checkout the source branch
  • then simply follow the exact same steps (starting from 2) but SKIP the hexo init command

Installing hexo

Please note that all commands are to be executed within the Git Bash.

  1. Create a new directory that will hold your blog

    1
    2
    mkdir myblog
    cd myblog
  2. Install the hexo framework and the git deployer

    1
    2
    3
    npm install hexo-cli -g
    npm install hexo-deployer-git --save
    hexo -v
  3. Initialize your blog

    1
    2
    3
    hexo init
    npm install
    hexo serve
  4. Now browse to http://localhost:4000 and enjoy your first blog

  5. You’re good to go, next steps would be:

    • customizing _config.yml to your likings
    • creating your first post by running hexo new

Deploying

The hexo git deployer has taken all the hard work out of deploying your blog to your master repo.

  1. First load your Github private key inside the Git Bash

    1
    2
    eval `ssh-agent`
    ssh-add ~/.ssh/github_rsa_key
  2. Now simply generate and deploy your blog

    1
    hexo generate -d