问题描述
执行启动服务预览命令 hexo server 报如下错误:
➜ sessionChBlog git:(master) ✗ hexo server
INFO Start processing
FATAL Something's wrong. Maybe you can find the solution here: http://hexo.io/docs/troubleshooting.html
Template render error: (unknown path) [Line 14, Column 32]
Error: Unable to call `wordcount`, which is undefined or falsey
at Object.exports.prettifyError (/Users/sessionCh/SessionCh/sessionChBlog/node_modules/nunjucks/src/lib.js:34:15)
at /Users/sessionCh/SessionCh/sessionChBlog/node_modules/nunjucks/src/environment.js:486:31
at root [as rootRenderFunc] (eval at <anonymous> (/Users/sessionCh/SessionCh/sessionChBlog/node_modules/nunjucks/src/environment.js:565:24), <anonymous>:18:3)
at Obj.extend.render (/Users/sessionCh/SessionCh/sessionChBlog/node_modules/nunjucks/src/environment.js:479:15)
at Obj.extend.renderString (/Users/sessionCh/SessionCh/sessionChBlog/node_modules/nunjucks/src/environment.js:327:21)
at /Users/sessionCh/SessionCh/sessionChBlog/node_modules/hexo/lib/extend/tag.js:66:9
at Promise._execute (/Users/sessionCh/SessionCh/sessionChBlog/node_modules/bluebird/js/release/debuggability.js:300:9)
at Promise._resolveFromExecutor (/Users/sessionCh/SessionCh/sessionChBlog/node_modules/bluebird/js/release/promise.js:483:18)
at new Promise (/Users/sessionCh/SessionCh/sessionChBlog/node_modules/bluebird/js/release/promise.js:79:10)
at Tag.render (/Users/sessionCh/SessionCh/sessionChBlog/node_modules/hexo/lib/extend/tag.js:64:10)
at Object.tagFilter [as onRenderEnd] (/Users/sessionCh/SessionCh/sessionChBlog/node_modules/hexo/lib/hexo/post.js:266:16)
at /Users/sessionCh/SessionCh/sessionChBlog/node_modules/hexo/lib/hexo/render.js:65:19
at tryCatcher (/Users/sessionCh/SessionCh/sessionChBlog/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/sessionCh/SessionCh/sessionChBlog/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/Users/sessionCh/SessionCh/sessionChBlog/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/Users/sessionCh/SessionCh/sessionChBlog/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/Users/sessionCh/SessionCh/sessionChBlog/node_modules/bluebird/js/release/promise.js:693:18)
at Async._drainQueue (/Users/sessionCh/SessionCh/sessionChBlog/node_modules/bluebird/js/release/async.js:133:16)
at Async._drainQueues (/Users/sessionCh/SessionCh/sessionChBlog/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues [as _onImmediate] (/Users/sessionCh/SessionCh/sessionChBlog/node_modules/bluebird/js/release/async.js:17:14)
at tryOnImmediate (timers.js:543:15)
at processImmediate [as _immediateCallback] (timers.js:523:5)
➜ sessionChBlog git:(master) ✗
解决方案
报错的原因是,hexo 转义时候发生的错误,可能是你的文章中存在特殊字符,如:{{ ( ) }} 这类符号,你需要对这类特殊符号使用转义字符。
注意:需要转义的字符只是文本中的特殊字符,代码块中的特殊字符无需使用转义字符。
如下面这段代码,转义前后对比:
常见特殊字符
! ! — 惊叹号 Exclamation mark
” " " 双引号 Quotation mark
# # — 数字标志 Number sign
$ $ — 美元标志 Dollar sign
% % — 百分号 Percent sign
& & & Ampersand
‘ ' — 单引号 Apostrophe
( ( — 小括号左边部分 Left parenthesis
) ) — 小括号右边部分 Right parenthesis
* * — 星号 Asterisk
+ + — 加号 Plus sign
< < < 小于号 Less than
= = — 等于符号 Equals sign
> > > 大于号 Greater than
? ? — 问号 Question mark
@ @ — Commercial at
[ [ --- 中括号左边部分 Left square bracket
\ \ --- 反斜杠 Reverse solidus (backslash)
] ] — 中括号右边部分 Right square bracket
{ { — 大括号左边部分 Left curly brace
| | — 竖线Vertical bar
} } — 大括号右边部分 Right curly brace
原文链接:http://sessionch.com/hexo/hexo-common-markdown.html
相关文章:Hexo添加字数统计、阅读时长