Hexo

Hexo备份

选择第三方git代码托管服务商进行备份,如github,coding,oschina等,我选择的是oschina和coding,因为你的站点配置文件或者主题配置文件中可能会涉及一些私密信息
,为了相对安全性,最好选择私有仓库进行备份,oschina和coding目前可建立免费的私有仓库。

推荐一个插件:hexo-git-backup,使用简单方便。

安装:

1
npm install hexo-git-backup

修改站点配置文件_config.yml,加入以下内容:

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

提交备份:

1
hexo b

如果想在其他机器上写博客,只需将仓库克隆,切换到站点目录下运行:

1
npm install

hexo g报错(Hexo: 3.2.0版本):Cannot read property ‘updated’ of undefined

hexo升级为3.2.0版本之后,hexo g报错:

1
2
3
4
5
6
7
8
9
FATAL ejs:7
5| <link href="<%- encodeURI(feed_url) %>" rel="self"/>
6| <link href="<%- encodeURI(url) %>"/>
>> 7| <updated><%= posts.first().updated.toISOString() %></updated>
8| <id><%- url %></id>
9| <% if (config.author){ %>
10| <author>

Cannot read property 'updated' of undefined

打开站点根目录文件:package.json,修改”dependencies”中hexo版本为:3.1.1,删除node_modules文件夹,重新运行:npm install
修改前:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{
"name": "hexo-site",
"version": "0.0.0",
"private": true,
"hexo": {
"version": "3.2.0"
}
,

"dependencies": {
"hexo": "^3.1.1",
"hexo-deployer-git": "0.0.4",
"hexo-generator-archive": "^0.1.2",
"hexo-generator-category": "^0.1.2",
"hexo-generator-feed": "~1.0.3",
"hexo-generator-index": "^0.1.2",
"hexo-generator-search": "^1.0.2",
"hexo-generator-sitemap": "~1.0.1",
"hexo-generator-tag": "^0.1.1",
"hexo-git-backup": "^0.1.2",
"hexo-renderer-ejs": "^0.1.0",
"hexo-renderer-marked": "^0.2.4",
"hexo-renderer-stylus": "^0.2.0",
"hexo-server": "^0.1.3"
}

}

修改后:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{
"name": "hexo-site",
"version": "0.0.0",
"private": true,
"hexo": {
"version": "3.2.0"
}
,

"dependencies": {
"hexo": "3.1.1",
"hexo-deployer-git": "0.0.4",
"hexo-generator-archive": "^0.1.2",
"hexo-generator-category": "^0.1.2",
"hexo-generator-feed": "~1.0.3",
"hexo-generator-index": "^0.1.2",
"hexo-generator-search": "^1.0.2",
"hexo-generator-sitemap": "~1.0.1",
"hexo-generator-tag": "^0.1.1",
"hexo-git-backup": "^0.1.2",
"hexo-renderer-ejs": "^0.1.0",
"hexo-renderer-marked": "^0.2.4",
"hexo-renderer-stylus": "^0.2.0",
"hexo-server": "^0.1.3"
}

}

热评文章