Hexo备份与搭建

#Hexo搭建

1
2
3
4
mkdir hexo  #创建一个文件夹
cd hexo
npm install -g hexo-cli
npm install hexo --save

部署Hexo:在Git shell 中输入

1
hexo init

安装Hexo 插件:自动生成sitemap,Rss,部署到git等,建议安装

1
2
3
4
5
6
7
8
9
10
11
12
13
npm install hexo-generator-index --save
npm install hexo-generator-archive --save
npm install hexo-generator-category --save
npm install hexo-generator-tag --save
npm install hexo-server --save
npm install hexo-deployer-git --save
npm install hexo-deployer-heroku --save
npm install hexo-deployer-rsync --save
npm install hexo-deployer-openshift --save
npm install hexo-renderer-marked@0.2 --save
npm install hexo-renderer-stylus@0.2 --save
npm install hexo-generator-feed@1 --save
npm install hexo-generator-sitemap@1 --save


Git获取SSHKey

  1. 打开 Git Bash.
  2. Paste the text below, substituting in your GitHub email address.
    1
    2
    3
    ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
    or
    ssh-keygen -t rsa -C "your_email@youremail.com"

3.回车3次

4.在Git Bash 输入

1
2
ssh -T git@github.com
ssh -T git@git.coding.net

测试是否生效

5.如下提示说明成功

1
2
Hi username! 
You've successfully authenticated, but GitHub does not provide shell access.


Git-backup

Install

if version is 3.x.x, you should install as follow:

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

Update

if you install with –save, you must remove firstly when you update it.

1
2
$ npm remove hexo-git-backup
$ npm install hexo-git-backup --save

Configure

You should configure this plugin in _config.yml.

1
2
3
4
5
backup:
type: git
repository:
github: git@github.com:xxx/xxx.git,branchName
gitcafe: git@github.com:xxx/xxx.git,branchName

Using

1
hexo backup

or

1
hexo b

Options

if you want to back up with your theme,just add theme: your theme name,your theme name in _config.yml.

1
2
3
4
5
6
backup:
type: git
theme: coney,landscape,xxx
repository:
github: git@github.com:xxx/xxx.git,branchName
gitcafe: git@github.com:xxx/xxx.git,branchName

Attention: if you do as above, the dir themes/coney/.gitwill be removed

if you want DIY commit message, just add ‘message: update xxx’.

1
2
3
4
5
6
backup:
type: git
message: update xxx
repository:
github: git@github.com:xxx/xxx.git,branchName
gitcafe: git@github.com:xxx/xxx.git,branchName

Now you can backup all the blog!

Problems

You may get some troubles by your computer’ permission。

###Error: EISDIR, open
it is caused by permission.
just do ‘sudo hexo b’

1
sudo hexo b