Hexo Migration

The following code is only tested on Apple Silicon.

  1. Config Git

    1
    2
    3
    4
    5
    git config user.name <your_name>
    git config user.email <your@email.address>
    git config -l # list git config
    ssh-keygen -t rsa -C "your@email.address"
    cat ~/.ssh/id_rsa.pub

    Copy rsa public key to GitHub->Settings->SSH and GPG keys.

  2. Install Nodejs

    1. In China, you may consider install cnpm

      1
      sudo npm install -g cnpm --registry=https://registry.npm.taobao.org
    2. In the following steps, I will use cnpm, same for npm.

  3. Install hexo with npm cnpm install -g hexo-cli

  4. Install deployment plugin cnpm install --save hexo-deployer-git

  5. Install Homebrew

    In China, you may consider HomebrewCN

    1
    /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
  6. Math equation rendering

    1. Install pandoc brew install pandoc

      1. If Error: Command failed with exit 128: git

        1
        2
        git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-core
        git config --global --add safe.directory /opt/homebrew/Library/Taps/homebrew/homebrew-cask
    2. Uninstall hexo-renderer-marked npm uninstall hexo-renderer-marked --save

    3. Install hexo-renderer-pandoc npm install hexo-renderer-pandoc

  7. Support local search in Next theme

    1. install plug-in

      1
      2
      npm install hexo-generator-search --save
      npm install hexo-generator-searchdb --save
    2. set local search to true in Next config file

      1
      2
      local_search:
      enable: true
  8. Done! 🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉

  9. hexo clean; hexo g; hexo d

  10. Here is two shell scripts for you

  11. blog.sh

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/zsh
# read input
name=$''
filename=$''
for arg in "$*"
do
name=$s$arg
done

# create new post
hexo n "$name"

# open post
name=$(echo $name|sed "s/ /-/g") # replace space with short dash
open $'./source/_posts/'$name$'.md' # open markdown file

  1. deploy.sh

1
2
3
4
5
6
7
#!/bin/zsh
hexo clean
hexo g
hexo clean
hexo d
clear
echo "Blog depolyment done! Let's post more! 🎉🎉🎉"