How To Rebuild Hexo

Step 1

Copy files and directories below to new device:

1
2
3
4
5
- _config.yml
- package.json
- scaffolds/
- source/
- themes/

Create a directory named hexo to store them and the instructs followed run under this path(~/hexo/) unless otherwise stated .

Step 2

Install Node.js(recommend node-v4.4.1-x64.msi, using other versions may meet different problems)

Step 3

Install hexo:

1
npm install -g hexo

If you wait for a long time and there isn’t any progress. Please execute the instructs below:

1
2
3
npm config set registry http://registry.cnpmjs.org
npm info underscore -- to see whether the first instruct executed successly
npm --registry http://registry.cnpmjs.org info underscore

Step 4

Install dependencies:

1
2
3
4
npm install
npm install hexo-deployer-git --save
npm install hexo-generator-feed --save
npm install hexo-generator-sitemap --save

Step 5

Login in git account:

1
2
git config --global user.name "your git account"
git config --global user.email "the email you used when you registered git account"

更详细的可见 hexo d命令报错问题

Step 6

Backup “themes/next/“. Clone the theme(here use next as example):

1
git clone https://github.com/iissnan/hexo-theme-next themes/next

Delete all files and directories under “themes/next/“ besides “.github”. Restore “themes/next/“ you backup before and execute the instructs below(under ~/hexo/themes/next/):

1
2
git add -A
git commit

Step 7

Generate and deploy:

1
hexo g -d

Other Instructions

  1. I execute setp 7 after step 4 and system prompt:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    INFO Deploying: git
    INFO Setting up Git deployment...
    Initialized empty Git repository in C:/hexo/.deploy_git/.git/
    *** Please tell me who you are.
    Run
    git config --global user.email "you@example.com"
    git config --global user.name "Your Name"
    ...
  2. Your blog may be whole white without step 6.

  3. Clean Cache:
    delete directory “~/hexo/.deploy_git/“
    execute:

    1
    hexo clean
  4. The progress info may stuck in half way. You probably don’t believe it that it’s caused to the slow internet. (说起来你可能不相信,这全赖网速慢)

  5. I try to add “~/hexo/public/“ to git and interrupt in half way and I don’t know the effect.

  6. My blog lack some modules at one time and don’t lack any modules suddenly.


    pic

Some Tips

  1. Add Portrait
    Revise the attribution of avatar in “~/hexo/themes/next/_config.yml”:

    1
    2
    3
    avatar: /uploads/avatar.png
    or
    avatar: http://...
  2. Add Friend Link
    Add these codes at the tail of “~/hexo/themes/next/_config.yml”

    1
    2
    3
    4
    5
    6
    # Blogrolls
    links_title: 友情链接
    #links_layout: block
    #links_layout: inline
    links:
    围城: blog.callouweicheng.cn
  3. remove the useless label at the bottom of blog
    revise “~/hexo/themes/next/layout/_partials/footer.swig”. The final result:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    <div class="copyright" >
    {% set current = date(Date.now(), "YYYY") %}
    &copy; {% if theme.since and theme.since != current %} {{ theme.since }} - {% endif %}
    <span itemprop="copyrightYear">{{ current }}</span>
    <span class="with-love">
    <i class="fa fa-heart"></i>
    </span>
    <span class="author" itemprop="copyrightHolder">{{ config.author }}</span>
    </div>
    {% block footer %}{% endblock %}

References