修改Chirpy主题后Jekyll站点构建失败求助
问题排查:Jekyll Chirpy主题构建失败(YAML语法错误)
问题描述
使用Jekyll的Chirpy主题,仅修改了_config.yml和_data/contact.yml文件,运行bundle exec jekyll s启动服务器时站点构建失败,恢复文件原状则无报错,GitHub Pages部署也存在相同问题。已尝试重新安装依赖、恢复初始模板、调整格式,问题仍未解决。
报错信息
montyhucknall@Monty MontyHucknall.github.io % bundle exec jekyll s --trace Configuration file: /Users/montyhucknall/Actual blog repository/MontyHucknall.github.io-1/MontyHucknall.github.io/_config.yml Source: /Users/montyhucknall/Actual blog repository/MontyHucknall.github.io-1/MontyHucknall.github.io Destination: /Users/montyhucknall/Actual blog repository/MontyHucknall.github.io-1/MontyHucknall.github.io/_site Incremental build: disabled. Enable with --incremental Generating... bundler: failed to load command: jekyll (/Users/montyhucknall/.rbenv/versions/3.2.2/bin/jekyll) /Users/montyhucknall/.rbenv/versions/3.2.2/lib/ruby/3.2.0/psych/parser.rb:62:in `_native_parse': (/Users/montyhucknall/Actual blog repository/MontyHucknall.github.io-1/MontyHucknall.github.io/_data/contact.yml): did not find expected '-' indicator while parsing a block collection at line 3 column 1 (Psych::SyntaxError)
当前contact.yml内容
# The contact options. - type: github icon: "fab fa-github" - type: twitter icon: "fa-brands fa-x-twitter" - type: email icon: "fas fa-envelope" noblank: true # open link in current tab - type: rss icon: "fas fa-rss" noblank: true # Uncomment and complete the url below to enable more contact options # # - type: mastodon # icon: 'fab fa-mastodon' # icons powered by <https://fontawesome.com/> # url: '' # Fill with your Mastodon account page, rel="me" will be applied for verification # - type: linkedin icon: 'fab fa-linkedin' # icons powered by <https://fontawesome.com/> url: 'https://www.linkedin.com/in/monty-hucknall-719272282/' # Fill with your Linkedin homepage # # - type: stack-overflow # icon: 'fab fa-stack-overflow' # url: '' # Fill with your stackoverflow homepage
解决方案
1. 修复YAML语法错误
- 替换转义引号:将文件中所有的
"替换为普通双引号",YAML解析器无法识别HTML转义的引号字符,这是导致语法错误的核心原因之一。 - 修正列表项格式:检查所有以
-开头的列表项,确保-是行首第一个字符(无前置空格)。比如你的LinkedIn条目行- type: linkedin需要改为- type: linkedin。
2. 验证YAML格式
可以在本地运行以下命令快速验证文件语法:
ruby -ryaml -e 'puts YAML.load_file("_data/contact.yml")'
如果没有报错,说明文件格式正确。
3. 重新构建站点
修复后重新运行启动命令:
bundle exec jekyll s
确认站点能正常构建,再尝试GitHub Pages部署。
内容的提问来源于stack exchange,提问作者Monty Hucknall
相关产品推荐
相关产品推荐

