Write the damn blog

1 hexo

install hexo
npm install -g hexo
generate static webpage
hexo g
run local server
hexo s
deploy to github
hexo d -g

1.1 config

modify your _config.yml or create my_config.yml according offical manual

1.2 theme

There is many great themes available. I like TKL the most. After download theme, change theme to maupassant in root _config.yml. Also theme's _config.yml can be modified.

  1. TKL

    1
    2
    3
    git clone https://github.com/SuperKieran/TKL.git themes/TKL
    cd themes/TKL
    git pull
  2. maupassant If encounter error while install sass, use taobao.

    1
    2
    3
    4
    git clone https://github.com/tufu9441/maupassant-hexo.git themes/maupassant
    npm install hexo-renderer-jade --save
    npm install -g cnpm --registry=http://registry.npm.taobao.org
    cnpm install hexo-renderer-sass --save
  3. air

    1
    2
    3
    4
    git clone https://github.com/litten/hexo-theme-yilia.git themes/yilia
    # Update from github
    cd themes/yilia
    git pull

1.3 github

  1. Modify deploy in _config.yml according to next lines.

    1
    2
    3
    4
    deploy:
    type: git
    repo: https://github.com/angry-bird/angry-bird.github.io.git
    branch: master
  2. Deploy local repo to github.

    1
    2
    3
    4
    5
    6
    npm i --save hexo-deployer-git
    git remote add origin https://github.com/angry-bird/angry-bird.github.io.git
    # git remote add origin git@github.com:angry-bird/angry-bird.github.io.git
    git checkout -b source
    git push origin source
    hexo g -d
  3. Deploy on both coing and github

    1
    2
    3
    4
    5
    6
    7
    deploy:
    - type: git
    repo: https://github.com/angry-bird/angry-bird.github.io.git
    branch: master
    - type: git
    repo: https://git.coding.net/zuoshi/angry-bird.github.io.git
    branch: master
    1
    2
    3
    4
    5
    deploy:
    type: git
    repo:
    github: git@github.com:angry-bird/angry-bird.github.io.git, master
    coding: git@git.coding.net:zuoshi/zuoshi.git, master
  4. connecting-to-github-with-ssh

1.4 hexo-renderer-org

  1. Install hexo-renderer-org

    [2018-11-10 Sat] should download this repo, not the orginal one which is outdated with emacs 26.1.

    1
    npm install https://github.com/MephistoMMM/hexo-renderer-org.git --save
    1
    2
    ### Outdated
    npm install https://github.com/CodeFalling/hexo-renderer-org#emacs --save
  2. Modify root _config.yml

    1
    2
    3
    4
    5
    6
    7
    8
    9
    org:
    emacs: '/usr/local/Cellar/emacs-plus/26.1/Emacs.app/Contents/MacOS/Emacs'
    emacsclient: '/usr/local/Cellar/emacs-plus/26.1/bin/emacsclient'
    common: |
    #+OPTIONS: toc:1 num:2 ^:{} creator:nil author:nil email:nil date:nil timestamp:nil
    #+BIND: org-html-validation-link nil
    line_number: true
    cachedir: './hexo-org-cache/'
    daemonize: true
  3. Misc
    Setting caption of image

    1
    2
    #+ATTR_HTML:  :alt caption
    [[image url]]

    Add Read more button, insert before first headline, and Table of Contents will be fine.

    1
    2
    3
    #+BEGIN_EXPORT html
    <!--more-->
    #+END_EXPORT

1.5 plugins

  1. plugins like sitemap, feed/rss, about, disqus/gitalk
    • about.html will generated from source/about.md

      1
      2
      npm install hexo-generator-sitemap -save
      npm install hexo-generator-feed -save
    • all plugins will generate to public/
  2. Disqus/duoshuo/Gitalk, but duoshuo is not available since July 2017, Gitalk is the substitution.
    • disqus shortname
    • install gitalk

      1
      npm i --save gitalk
      1
      2
      import 'gitalk/dist/gitalk.css'
      import Gitalk from 'gitalk'
    • github application

      1
      2
      3
      4
      5
      6
      7
      8
      9
      var gitalk = new Gitalk({
      clientID: 'your-client-id',
      clientSecret: 'your-client-secret',
      repo: 'angry-bird.github.io',
      owner: 'angry-bird',
      admin: ['angry-bird'],
      })

      gitalk.render('gitalk-container')

      Note that application name set as gitalk, homepage url is your blog's domain url, and authorization callback url is blog's github address. After that, copy Client ID and Client Secret, repo is owner.github.io

    • theme's _config.yml

1.6 widges on theme TKL

  1. widges like weibo, facebook, search, category, tagcloud
  2. baidustatic

    1
    2
    3
    4
    5
    6
    7
    8
    9
    <script>
    var _hmt = _hmt || [];
    (function() {
    var hm = document.createElement("script");
    hm.src = "https://hm.baidu.com/hm.js?c65795c17436c80c4127ae64076e5746";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(hm, s);
    })();
    </script>

2 blog-admin

1
2
3
4
5
6
(add-hook 'blog-admin-backend-after-new-post-hook 'find-file)
(setq blog-admin-backend-path "~/.blog")
(setq blog-admin-backend-type 'hexo)
(setq blog-admin-backend-new-post-in-drafts t)
(setq blog-admin-backend-new-post-with-same-name-dir t)
(setq blog-admin-backend-hexo-config-file "_config.yml")

3 other options

3.1 org-page

  1. melpa install package, but failed because incompatible dependency packages
  2. config repo and site
  3. publish

3.2 nikola