2 Build Blog on Windows by Node.js and Hexo

Description: This blog introduces how to build your own blog on windows OS. with the help of Node.js and Hexo

Install

Git

Download Git and register an account in GitHub ,

Make sure SSH is installed on your windows OS. Create DSA or RSA keys by running commands below

 
$ cd ~/.ssh * 
$ ssh-keygen -t rsa -C youremail@email.com  
 

Add the generated key rsa*.pub content to your GitHub

SSH keys New SSH key

Paste your ssh rsa.pub key to it

Setup your cmd/git hub bash ,tab

1
$ ssh -T git@github.com

Your will receive a message like this “Hi , welcome to git hub blabla “.

But now ,remember you have not got your token string yet which means you couldn’t ‘deploy’ your hexo blog to github.

Go to the GitHub Setting Page and press the Personal access tokens then Generate new token and confirm your password again .
Write in the token name (Token description) in order your can distinguish this token to other tokens , select scopes (just like setting functions of the token) , and the last step is press the green ‘Generate token’ button. Like this you’ll get your ‘Personal access tokens’

Open your git bash again , and tab in commands

 
$ git config --global user.name "your name" 
$ git config --global user.email "your email"
$ git config --global usr.token "paste the personal access tokens your just got here"
 

Node.js

Download Node.js for Windows

Install Node.js and add both Node.js and npm’s path to environment’s PATH

Create two folders with the name of ‘node_cache’ and ‘node_global’under node.js’s folder

Open git bash under current folder(by clicking right mouse -> git bash), and tab

 
$ npm config ls
$ npm config set cache 'the absolute path you created folder node_cache'
$ npm config set prefix 'the absolute path you created folder node_global'  
 

Hexo

Open your git bash again,change your current to one folder your want your hexo installed in, tab in

1
$ npm install hexo

Local Blog Server

After hexo installed , do not forget add the hexo(the executable binary file)’s location into env’s PATH too

Make a new folder which you want to store blog’s file and change current path to it

Tab in

 
$ hexo init         # this command like git init , initialize the blog workspace and generate files
$ npm install    # wait for a while
$ hexo g         # hexo g is the command which short for hexo generate
$ hexo s         # deploy your hexo template on localhost's server(0.0.0.0:4000)

Deploy Blog to Git(like this blog)

Create a new respo. on your github with the name ‘your github account name’.github.io

Deploy Blog to Git ‘s step is a little different from deploying it on local server

Open git bash on hexo blog’s path and tab in the commands below

 
$ hexo init 
$ npm install
$ npm install hexo-deployer-git --save # download git corresponding plugins

Open your _config.yml file , update the #Deployment’s part content like this

 
# Deployment
## Docs: http://hexo.io/docs/deployment.html
deploy:
  type: git
  repository: git@github.com:'your github account name'.github.io.git  #--> do not forget replace it
  branch: master

After update _config.yml file , tab in commands

1
$ hexo d    # short command for hexo deploy

Open your browser, and tab in https://'your github account name’.github.io you will see the blog your just create

If your want to add new blogs just add a new .md file (mark down edit style) under your blog’s source/_post/ folder

You can change your blog’s name by changing _config.yml’s ‘title’ content

Good luck !