hexo's tips


摘要:hexo小技巧汇总

如何修改新建文章模板

一般文章都需要添加分类和摘要,我们可以加到模板中。进入到hexo根目录的scaffolds下可以看到三个md文件:draft.md\page.md\post.md
在post.md中添加分类和摘要后:
图片1
这样新建文章的时候就包含分类和摘要了。

如何在博客中引用本地图片

首先修改_config.yml中参数 post_asset_folder:true,这样设置后在新建文章时,Hexo会自动创建一个与文章同名的文件夹用来存放图片
然后安装插件:npm install https://github.com/CodeFalling/hexo-asset-image --save
引用图片:将图片放在文章同名的文件夹中,比如图片名称:1.png,在md中书写:![图1](hexo-s-comment/1.png)即可。

报错日志及解决

1、发布博客遇到报错

YAMLException: can not read a block mapping entry; a multiline key may not be an implicit key at line 5, column 1:

报错原因:根据日志定位到第5行,第1列的内容是:categories:Hexo。分类冒号后面需要加个空格再写内容!
解决办法:改成categories: Hexo即可!
2、将博客发布到远程报错

ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
FATAL Something's wrong. Maybe you can find the solution here: http://hexo.io/docs/troubleshooting.html
Error: ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
at ChildProcess.<anonymous> (D:\src\Git\imdba\node_modules\hexo-util\lib\spawn.js:37:17)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at ChildProcess.cp.emit (D:\src\Git\imdba\node_modules\cross-spawn\lib\enoent.js:40:29)
at maybeClose (internal/child_process.js:877:16)
at Socket.<anonymous> (internal/child_process.js:334:11)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at Pipe._handle.close [as _onclose] (net.js:498:12)
FATAL ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Error: ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
at ChildProcess.<anonymous> (D:\src\Git\imdba\node_modules\hexo-util\lib\spawn.js:37:17)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at ChildProcess.cp.emit (D:\src\Git\imdba\node_modules\cross-spawn\lib\enoent.js:40:29)
at maybeClose (internal/child_process.js:877:16)
at Socket.<anonymous> (internal/child_process.js:334:11)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at Pipe._handle.close [as _onclose] (net.js:498:12)

报错原因:网络问题
解决办法:关闭VPN,重新发布即可。
3、执行hexo命令提示:bash: hexo: command not found
解决办法:将hexo的bin目录加入环境变量(D:\src\Git\imdba\node_modules\hexo\bin)
同时确保相关组件运行正常:
Administrator@dba MINGW64 /imdba/node_modules
$ npm -v
3.10.10

Administrator@dba MINGW64 /imdba/node_modules
$ node -v
v6.11.5

文章目录
  1. 1. 如何修改新建文章模板
  2. 2. 如何在博客中引用本地图片
  3. 3. 报错日志及解决
|