Hexo博客部署到GitHub:配置_config.yml的格式问题

在将搭建好的博客部署到GitHub时,需要配置_config.yml文件。在配置时要注意格式问题。

这是在Git Bash中执行$hexo d -g时遇到的问题(hexo ghexo generate的缩写,用于生成你写的博客文章;hexo dhexo deploy的缩写,用于将你写的文章部署到GitHub上):

问题描述:

yinshouxiang@LAPTOP-A5F9VAVK MINGW64 /e/MyBlog/MyBlog
$ hexo d -g
FATAL bad indentation of a mapping entry at line 102, column 2:
     repo: https://github.com/webysx/ ...
     ^
YAMLException: bad indentation of a mapping entry at line 102, column 2:
     repo: https://github.com/webysx/ ...
     ^
    at generateError (E:\MyBlog\MyBlog\node_modules\js-yaml\lib\js-yaml\loader.js:167:10)
    at throwError (E:\MyBlog\MyBlog\node_modules\js-yaml\lib\js-yaml\loader.js:173:9)
    at readBlockMapping (E:\MyBlog\MyBlog\node_modules\js-yaml\lib\js-yaml\loader.js:1107:7)
    at composeNode (E:\MyBlog\MyBlog\node_modules\js-yaml\lib\js-yaml\loader.js:1359:12)
    at readDocument (E:\MyBlog\MyBlog\node_modules\js-yaml\lib\js-yaml\loader.js:1519:3)
    at loadDocuments (E:\MyBlog\MyBlog\node_modules\js-yaml\lib\js-yaml\loader.js:1575:5)
    at Object.load (E:\MyBlog\MyBlog\node_modules\js-yaml\lib\js-yaml\loader.js:1596:19)
    at Hexo.yamlHelper (E:\MyBlog\MyBlog\node_modules\hexo\lib\plugins\renderer\yaml.js:7:15)
    at Hexo.tryCatcher (E:\MyBlog\MyBlog\node_modules\bluebird\js\release\util.js:16:23)
    at Hexo. (E:\MyBlog\MyBlog\node_modules\bluebird\js\release\method.js:15:34)
    at E:\MyBlog\MyBlog\node_modules\hexo\lib\hexo\render.js:75:22
    at tryCatcher (E:\MyBlog\MyBlog\node_modules\bluebird\js\release\util.js:16:23)
    at Promise._settlePromiseFromHandler (E:\MyBlog\MyBlog\node_modules\bluebird\js\release\promise.js:547:31)
    at Promise._settlePromise (E:\MyBlog\MyBlog\node_modules\bluebird\js\release\promise.js:604:18)
    at Promise._settlePromise0 (E:\MyBlog\MyBlog\node_modules\bluebird\js\release\promise.js:649:10)
    at Promise._settlePromises (E:\MyBlog\MyBlog\node_modules\bluebird\js\release\promise.js:729:18)
    at _drainQueueStep (E:\MyBlog\MyBlog\node_modules\bluebird\js\release\async.js:93:12)
    at _drainQueue (E:\MyBlog\MyBlog\node_modules\bluebird\js\release\async.js:86:9)
    at Async._drainQueues (E:\MyBlog\MyBlog\node_modules\bluebird\js\release\async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (E:\MyBlog\MyBlog\node_modules\bluebird\js\release\async.js:15:14)
    at processImmediate (internal/timers.js:439:21)

Hexo博客部署到GitHub:配置_config.yml的格式问题_第1张图片
这个问题是由于在配置_config.yml文件的过程中没有严格按照规定的格式。

①在": "后面必须要加一个空格;
②在type,repo,branch前面加两个空格或一个水平制表符(Tab键)。

正确写法:

deploy:
  type: git
  repo: https://github.com/webysx/webysx.github.io.git
  branch: master
或
deploy:
	type: git
	repo: https://github.com/webysx/webysx.github.io.git
	branch: master

修改好之后,再次执行hexo d -g,问题解决。
Hexo博客部署到GitHub:配置_config.yml的格式问题_第2张图片

你可能感兴趣的:(Hexo博客部署到GitHub:配置_config.yml的格式问题)