github - 由于 YAML 错误,Hugo 无法使用 GitHub Pages 构建

标签 github markdown jekyll github-pages hugo

我在 Github Pages 上使用 Hugo,每当我将我的网站推送到 origin 时,我都会收到以下错误消息:

The page build failed for the master branch with the following error: There was a YAML syntax error on line 2 column 1 in <unknown>: did not find >expected key while parsing a block mapping. For more information, see >https://help.github.com/articles/page-build-failed-invalid-yaml-in-data-file/. For information on troubleshooting Jekyll see: https://help.github.com/articles/troubleshooting-jekyll-builds If you have any questions you can contact us by replying to this email.

我该如何解决这个问题?我听说在根目录下制作一个 .nojekyll 文件有帮助,但我不知道该怎么做

我在网上尝试了一些没有用的解决方案,我在根目录下创建了一个 nojekyll.nojekyll 文件,希望能禁用 Jekyll,如果这是问题所在...

最佳答案

使用.nojekyll告诉 Github 不要使用 Jekyll 处理你的文件,所以在你构建站点之后,只需将 .nojekyll 文件放在 gh-page 的根目录或 docs 文件夹。

例如,将Hugo生成的文件全部移动到docs文件夹中,在/docs中放置一个.nojekyll空文件。然后选择 docs 文件夹作为 Github 页面文件的容器,Github 将提供这些文件。

如果你想看一个活生生的例子,我在这个主题中使用了这种方法 https://github.com/marcanuy/simpleit-hugo-theme并且工作正常,生成的网站在 https://marcanuy.github.io/simpleit-hugo-theme/ 提供服务使用以下 Make 自动执行的方法:

generate-githubpages:
    rm -fr docs && HUGO_ENV=production $(HUGO) --baseURL https://marcanuy.github.io/simpleit-hugo-theme/ --source=exampleSite --themesDir=../.. --config ../config-github-docs.toml && mv exampleSite/public docs && touch docs/.nojekyll
clean:
    rm -fr exampleSite/public/

您可以在 Publishing your GitHub Pages site from a /docs folder on your master branch 阅读更多内容。 ).

关于github - 由于 YAML 错误,Hugo 无法使用 GitHub Pages 构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54739382/

相关文章:

github - 如何使用curl 和 GraphQL updateIssueComment 突变更新 Github 中的问题或 PR 评论

markdown - 如何在应用程序中使用Stackedit的 Markdown 编辑器

Meteor:从文件导入 markdown

linux - 无法克隆 github 存储库

git - github 私有(private)仓库中的 Terraform 模块

github - 如何在github Action中传递json文件?

html - Jekyll网站无法使用 "github-pages"Jekyll插件正确将markdown和liquid转换为html

ruby - 在本地运行 jekyll 时出错(rvm gemset 问题)

javascript - 如何重置某个 div 的所有 css 样式? (杰基尔博客)

ruby - “未安装 Pygments gem 或其依赖项之一”错误消息