Building Personal Website with Github

 Nodejs
 

A tutorial for building your own website make use of github and hexo, with a beautiful theme “material-x”.

Install hexo

​ You should alread install git and nodejs.

1
$ npm install -g hexo-cli

​ Hexo create a directory for your project:

1
2
$ hexo init <folder>
$ cd <folder>

​ Hexo will build a skeleton for your site:

1
$ npm install

​ Test whether everything is ok:

1
$ hexo server

​ If it works well. you can change the theme, which can be found on hexo site. I will use material-x theme :

1
2
$ cd themes
$ git clone https://github.com/xaoxuu/hexo-theme-material-x themes/material-x

​ Then install dependencies:

1
$ npm i -S hexo-generator-search hexo-generator-feed hexo-renderer-less hexo-autoprefixer hexo-generator-json-content hexo-recommended-posts hexo-helper-qrcode

​ Go to the your project’s root directory, and configure the file _config.yml.

​ Item theme: change its value to your theme’s name, for example:

1
theme: material-x

Install git deploy plugin

​ Look for deploy item ,and modify it like follow:

1
2
3
4
deploy:
type: git
repo: git@github.com:wjwrobot/wjwrobot.github.io.git
branch: master

​ After that we are going to install git deploy plugin:

1
$ npm install hexo-deployer-git --save

​ Latsly, you can configure your theme according to this tutorial .

Deploy to your github website

​ Before deploy it to github, test it on local machine:

1
2
$ hexo generator # or hexo g
$ hexo server # or hexo s

​ Open a browser ,input following address:

1
http://localhost:4000/

​ If work well deploy it to github

1
$ hexo deploy # or hexo d

Create a repo for your theme

​ Change your pwd to your installed theme directory. Then use browser to create a repo and name it (e.g.hexo-theme-material-x). Change remote origin to your repo and add the origin author’s repo as remote upstream for later updating.

1
2
3
4
5
$ git remote -v
$ git remote remove origin
$ git remote add origin https://github.com/wjwrobot/hexo-theme-material-x.gi
$ git push origin master
$ git remote add upstream https://github.com/xaoxuu/hexo-theme-material-x.git

​ If upstream has update, you can use fetch command to get it and merge upstream/master to local master:

1
2
$ git fetch upstream
$ git merge upstream/master

​ Push to remote repo:

1
$ git push origin master