Build blog with Hexo and MWeb

Requirements

Github account: blog deployed by GitHub Pages
Hexo: blog framework to generate static blog files
MWeb: Markdown writing tool

Setup Github

  1. Create a new repository named username.github.io
  2. https://username.github.io will be your personal blog address

Setup Hexo

Make sure you have installed node.js and git.

1
2
3
4
$ npm install -g hexo-cli
$ hexo init blog
$ cd blog
$ hexo new "my first blog"

Setup MWeb

  1. Install MWeb in App Store
  2. Lauch MWeb and go into External Mode (Command + E)
  3. Add new external source: {blog}/source, and choose Media Save Path as Absolute
  4. Enjoy writing

Deploy Blog

  1. Install hexo-deployer-git

    1
    $ npm install hexo-deployer-git --save
  2. Edit {blog}/_config.yml

    1
    2
    3
    4
    5
    6
    7
    $ vim _config.yml
    # Deployment
    deploy:
    type: git
    repo: git@github.com:username/username.github.io.git
    branch: master
  3. Deploy after you make any changes

    1
    $ hexo deploy -g
  4. You can also test local: http://0.0.0.0:4000/

    1
    $ hexo server

Tips

  1. Back up source folder and add version control: markdown source files will be inside {blog}/source and this folder will not be tracked by git. So I sync this important folder to cloud:

    1
    2
    3
    4
    5
    $ cp -r {blog}/source {Dropbox}/blog/source
    $ vim _config.yml # point source_dir to the new synced path
    # Directory
    source_dir: {Dropbox}/blog/source
  2. Add README.md to repo: create README.md inside {source} folder and modify {blog}/_config.yml, so that README.md can introduce your repo on github:

    1
    2
    3
    4
    $ vim _config.yml
    # Directory
    skip_render: README.md

Ref: Hexo, MWeb for Octpress

Contents
  1. 1. Requirements
  2. 2. Setup Github
  3. 3. Setup Hexo
  4. 4. Setup MWeb
  5. 5. Deploy Blog
  6. 6. Tips
|