The note of how to rebuild hexo+next blogs when switch to another PC or reinstall system

Preface

We have pointed out using git to backup our blogs’ content in the before articles: Use Hexo+Next+git build a blog system in GitHub page. The following will show the details of how to rebuild hexo+next blogs when switch to another PC or reinstall system.

Clone the backup files

I use the Linux system and have installed git service, so I can use git to clone my blog content from my private repository in csdn code:

1
git clone https://code.csdn.net/mduanfire/hexo-notes.git

Download and install node and npm

Please visit these page to look for the details:node website and Install DOC

Install nodejs in ubuntu:

1
2
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs

If you want to update inside npm, do

1
2
3
sudo npm cache clean -f
sudo npm install -g n
sudo n stable

Set npm source from taobao

// Ubuntu

1
2
3
4
5
6
sudo npm install -g npm --registry=https://registry.npm.taobao.org
sudo npm install -g cnpm --registry=https://registry.npm.taobao.org
sudo npm install -g bower --registry=https://registry.npm.taobao.org

// option,set default npm source data from taobao
sudo npm config set registry "https://registry.npm.taobao.org"

// Windows

1
2
3
4
5
6
npm install -g npm --registry=https://registry.npm.taobao.org
npm install -g cnpm --registry=https://registry.npm.taobao.org
npm install -g bower --registry=https://registry.npm.taobao.org

// option,set default npm source data from taobao
npm config set registry "https://registry.npm.taobao.org"

Install hexo and Plugins we need

1
2
3
4
5
6
7
8
9
// install hexo
sudo npm install -g hexo-cli

// switch dir
cd /hexo-notes/notes

// npm install
sudo npm install
sudo npm install hexo-deployer-git --save

Install email remind Plugins

1
2
3
4
5
6
7
8
9
10
11
cd /hexo-notes/notes/emailCallbak

// ensure emailCallbak dir is null,
// or will get error: npm ERR! ENOTEMPTY: directory not empty
mv adduser.js /home/dm/

// install request
sudo npm install --save-dev request

// move back
mv /home/dm/adduser.js .

Install article visit count Plugins

1
2
3
sudo npm install --save hexo-generator-index
sudo npm install --save hexo-generator-archive
sudo npm install --save hexo-generator-tag

Install sitemap Plugins

1
sudo npm install hexo-generator-sitemap --save

Note if meet the error as following:

if npm ERR! ENOTEMPTY: directory not empty, rename ‘/home/dm/hexo-notes/notes/node_modules/hexo-generator-sitemap’ -> ‘/home/dm/hexo-notes/notes/node_modules/.hexo-generator-sitemap.DELETE’

Solution: please rm -rf *.DELETE and reinstall.

Deploy

1
2
3
4
5
6
7
cd /hexo-notes/notes/

// clean
sudo hexo clean

// deploy
sudo hexo g -d

Publish new article

1
2
3
4
5
6
7
8
9
10
cd /hexo-notes/notes/

// generate new article
sudo hexo n "article name"

~~~~ writing ~~~~

// after finished article, Deploy
sudo hexo clean
sudo hexo g -d

Issues

1/ bash: /dev/tty: No such device or address

if you deploy again, and meet the error follow:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

bash: /dev/tty: No such device or address

error: failed to execute prompt script (exit code 1)

fatal: could not read Username for 'https://github.com': No error

FATAL Something's wrong. Maybe you can find the solution here: http://hexo.io/docs/trouble...

Error: bash: /dev/tty: No such device or address

error: failed to execute prompt script (exit code 1)

fatal: could not read Username for 'https://github.com': No error

at ChildProcess.<anonymous> (E:\zan\www\gitpages\hexo\xxxxx.github.io\node_modules\hexo-deployer-git\node_modules\hexo-util\lib\spawn.js:42:17)

at emitTwo (events.js:87:13)

at ChildProcess.emit (events.js:172:7)

at maybeClose (internal/child_process.js:818:16)

at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)

Solution:

reinstall hexo-deployer-git:

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

2/ use ssh with git

https met error or is slow, please use ssh for git.

Reference

[1]. https://hexo.io/docs/troubleshooting.html


END

Enjoy it ? Donate me ! 求鼓励,求支持!
0%