Hexo之编译Bug

bug模版

  • bug
  • 发生日期
  • 类型
  • 出现过程
  • 日志 log
  • bug分析
  • 解决办法

更新状态:持续更新中…

1.bug

发生日期

2018年1月12日下午4:11

类型

YAMLException

出现过程

将Mou编辑好的md文件“基于hexo+github搭建独立博客.md”,通过Finder移动到hexo/blog目录

日志log
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
ERROR Process failed: _posts/基于hexo+github搭建独立博客.md
YAMLException: end of the stream or a document separator is expected at line 17, column 1:
1. 准备
^
at generateError (/Users/lixing/hexo/blog/node_modules/js-yaml/lib/js-yaml/loader.js:165:10)
at throwError (/Users/lixing/hexo/blog/node_modules/js-yaml/lib/js-yaml/loader.js:171:9)
at readDocument (/Users/lixing/hexo/blog/node_modules/js-yaml/lib/js-yaml/loader.js:1512:5)
at loadDocuments (/Users/lixing/hexo/blog/node_modules/js-yaml/lib/js-yaml/loader.js:1548:5)
at Object.load (/Users/lixing/hexo/blog/node_modules/js-yaml/lib/js-yaml/loader.js:1569:19)
at parseYAML (/Users/lixing/hexo/blog/node_modules/hexo-front-matter/lib/front_matter.js:80:21)
at parse (/Users/lixing/hexo/blog/node_modules/hexo-front-matter/lib/front_matter.js:56:12)
at /Users/lixing/hexo/blog/node_modules/hexo/lib/plugins/processor/post.js:52:18
at tryCatcher (/Users/lixing/hexo/blog/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/lixing/hexo/blog/node_modules/bluebird/js/release/promise.js:509:35)
at Promise._settlePromise (/Users/lixing/hexo/blog/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/Users/lixing/hexo/blog/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/Users/lixing/hexo/blog/node_modules/bluebird/js/release/promise.js:693:18)
at Promise._fulfill (/Users/lixing/hexo/blog/node_modules/bluebird/js/release/promise.js:638:18)
at PromiseArray._resolve (/Users/lixing/hexo/blog/node_modules/bluebird/js/release/promise_array.js:126:19)
at PromiseArray._promiseFulfilled (/Users/lixing/hexo/blog/node_modules/bluebird/js/release/promise_array.js:144:14)
at PromiseArray._iterate (/Users/lixing/hexo/blog/node_modules/bluebird/js/release/promise_array.js:114:31)
at PromiseArray.init [as _init] (/Users/lixing/hexo/blog/node_modules/bluebird/js/release/promise_array.js:78:10)
at Promise._settlePromise (/Users/lixing/hexo/blog/node_modules/bluebird/js/release/promise.js:566:21)
at Promise._settlePromise0 (/Users/lixing/hexo/blog/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/Users/lixing/hexo/blog/node_modules/bluebird/js/release/promise.js:693:18)
at Promise._fulfill (/Users/lixing/hexo/blog/node_modules/bluebird/js/release/promise.js:638:18)
bug分析
  1. hexo docs troubleshooting#YAML Parsing Error

  2. hexo github issue

搜索YAMLException: end of the stream or a document separator is expected

YAMLException issues

1
2
3
4
5
1.https://github.com/hexojs/hexo/issues/2717
Please add --- to the frontmatter, see https://hexo.io/docs/front-matter.html
2.https://github.com/hexojs/hexo/issues/2031
The content between first two --- will be treat as meta data.
So the npm was treat as a key, try to add a meta data to see if the problem fixed.

Front-matter is a block of YAML or JSON at the beginning of the file that is used to configure settings for your writings. Front-matter is terminated by three dashes when written in YAML or three semicolons when written in JSON.
Front-matter是在文件开头,用来配置文章设置项的YAML or JSON块,即配置元数据meta data。书写形式如下:

YAML

1
2
3
title: Hello World
date: 2013/7/13 20:46:25
---

JSON

1
2
3
"title": "Hello World",
"date": "2013/7/13 20:46:25"
;;;
解决方法
1
2
3
在“基于hexo+github搭建独立博客.md“文件开头添加文章设置项YAML块,主要是最后3破折号(英文版)。
md文章第一行3破折号:分割线
之后3破折号:段落分隔符

2.bug

发生日期

2018年1月12日下午4:20

类型

YAMLException

出现过程

在“基于hexo+github搭建独立博客.md”开头,添加Front-matter YAML块

1
2
3
4
---
title: 基于hexo+github搭建独立博客
date:2018年1月12日 下午4:28
---
日志log
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
ERROR Process failed: _posts/基于hexo+github搭建独立博客.md
YAMLException: can not read a block mapping entry; a multiline key may not be an implicit key at line 3, column 1:
^
at generateError (/Users/lixing/hexo/blog/node_modules/js-yaml/lib/js-yaml/loader.js:165:10)
at throwError (/Users/lixing/hexo/blog/node_modules/js-yaml/lib/js-yaml/loader.js:171:9)
at readBlockMapping (/Users/lixing/hexo/blog/node_modules/js-yaml/lib/js-yaml/loader.js:1046:9)
at composeNode (/Users/lixing/hexo/blog/node_modules/js-yaml/lib/js-yaml/loader.js:1332:12)
at readDocument (/Users/lixing/hexo/blog/node_modules/js-yaml/lib/js-yaml/loader.js:1492:3)
at loadDocuments (/Users/lixing/hexo/blog/node_modules/js-yaml/lib/js-yaml/loader.js:1548:5)
at Object.load (/Users/lixing/hexo/blog/node_modules/js-yaml/lib/js-yaml/loader.js:1569:19)
at parseYAML (/Users/lixing/hexo/blog/node_modules/hexo-front-matter/lib/front_matter.js:80:21)
at parse (/Users/lixing/hexo/blog/node_modules/hexo-front-matter/lib/front_matter.js:56:12)
at /Users/lixing/hexo/blog/node_modules/hexo/lib/plugins/processor/post.js:52:18
at tryCatcher (/Users/lixing/hexo/blog/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/lixing/hexo/blog/node_modules/bluebird/js/release/promise.js:509:35)
at Promise._settlePromise (/Users/lixing/hexo/blog/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/Users/lixing/hexo/blog/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/Users/lixing/hexo/blog/node_modules/bluebird/js/release/promise.js:693:18)
at Promise._fulfill (/Users/lixing/hexo/blog/node_modules/bluebird/js/release/promise.js:638:18)
at PromiseArray._resolve (/Users/lixing/hexo/blog/node_modules/bluebird/js/release/promise_array.js:126:19)
at PromiseArray._promiseFulfilled (/Users/lixing/hexo/blog/node_modules/bluebird/js/release/promise_array.js:144:14)
at PromiseArray._iterate (/Users/lixing/hexo/blog/node_modules/bluebird/js/release/promise_array.js:114:31)
at PromiseArray.init [as _init] (/Users/lixing/hexo/blog/node_modules/bluebird/js/release/promise_array.js:78:10)
at Promise._settlePromise (/Users/lixing/hexo/blog/node_modules/bluebird/js/release/promise.js:566:21)
at Promise._settlePromise0 (/Users/lixing/hexo/blog/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/Users/lixing/hexo/blog/node_modules/bluebird/js/release/promise.js:693:18)
at Promise._fulfill (/Users/lixing/hexo/blog/node_modules/bluebird/js/release/promise.js:638:18)
bug分析

Front-matter YAML块的date:格式与_config.xml#dateformat不一致。

解决办法

修改为date_format: YYYY-MM-DD
time_format: HH:mm:ss