【问题标题】:Jekyll treating YAML hyphens as dashesJekyll 将 YAML 连字符视为破折号
【发布时间】:2016-09-14 05:21:35
【问题描述】:

Jekyll 没有正确解析帖子,我找不到错误; YAML 前面的内容与我们其他帖子中的相同。以下是两个区别:

(1) 出于某种原因,Jekyll 将 YAML 前端内容底部的三个破折号渲染为一个破折号:category: German — Doch is a modal particle,。我已经尝试删除这些连字符并重新键入它们,但这并没有解决问题。

(2) 我们正在尝试使用此帖子创建一个名为“德语”的新类别。 Jekyll 自动从其他帖子创建了我们的类别,但在这种情况下,它并没有创建“德语”类别,而是将帖子放在自己的文件夹中。

当我在浏览器中打开页面时,我在顶部看到这个:

layout: post author: WordBrewery title: “How to use the German doch” description: “How to use and understand the German modal particle doch.” image: hohenschwangau.jpg featured: true published: true category: German — Doch is a modal particle, a word used to indicate attitude, tone or the focus of a sentence.

这里是 YAML 的前端和帖子的第一行:

---
layout: post
author: WordBrewery
title: "How to use the German doch"
description: "How to use and understand the German modal particle doch."
image: hohenschwangau.jpg
featured: true
published: true
category: German
---
*Doch* is a [modal particle](https://en.m.wikipedia.org/wiki/German_modal_particle), a word used to indicate attitude, tone or the 

如果有任何帮助,我将不胜感激。

Appearance of the unparsed post

【问题讨论】:

  • 文件的编码是否与正常工作的帖子不同?
  • 确保使用 utf-8 编码保存文件,没有 BOM。
  • 谢谢你们;我认为这可能是问题所在,并在 Emacs 中将编码重新保存为 utf-8(原件是在 Atom 的 Windows PC 上起草的),但显然这并没有删除 BOM(并且 BOM 在空白模式下不可见)。然后我切换到 Sublime Text 并尝试将其打开为 UTF-8 并将其保存为 UTF-8,这很有效。谢谢!
  • PS - 不幸的是,我的声誉为 1,似乎无法投票给您的 cmets。

标签: yaml jekyll github-pages


【解决方案1】:

(从 cmets 转到答案)

您需要确保markdown文件编码正确(utf8 no BOM)。 Jekyll 前面的 BOM 有问题http://jekyllrb.com/docs/frontmatter/

【讨论】:

  • 这真的很令人惊讶,因为 YAML 明确允许 BOM。
  • 是的,但是这个 YAML 位于 Jekyll 解析的降价文件的顶部。 Jekyll 的 BOM 有问题,特别警告jekyllrb.com/docs/frontmatter
猜你喜欢
  • 2018-11-20
  • 1970-01-01
  • 2015-02-26
  • 1970-01-01
  • 2014-06-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多