1

Scenario:

I have a variable within the front matter of every blog post which looks like the following:

---
icon: ☕
---

When I display a list of blog posts I reference this UTF-8 character

{% for post in site.posts %}
  <span class="icon">{{ post.icon }}</span>
{% endfor %}

I build the site locally, check localhost:4000 to make sure everything is fine, and then push to GitHub. My site is hosted by GitHub Pages and GitHub will build the site every time I push to master.

Problem:

The site looks fine when I build it locally. I can see the UTF-8 character displayed and when I check the source of the page it shows a span tag with the UTF-8 character.

<span class="icon">&#9749;</span>

However, the UTF-8 character is not visible on the website built by GitHub and the UTF-8 character is not within the span tag

<span class="icon"></span>

I have double checked and made sure that I have pushed everything to origin. Why is my UTF-8 character missing?

EDIT: I have solved my problem but I still do not know why it was happening. I think knowing why GitHub is failing to properly parse the front-matter is worth knowing and I will keep this question open until someone is able to find out

4

1 回答 1

1

看来我需要用引号将我的前面的 UTF-8 字符括起来:

---
icon: "&#9749;"
---

尽管在添加 icon 变量之前不需要这样做,但我还必须将所有其他的 front-matter 变量括在引号中。

---
layout: "default"
icon: "&#9749;"
---

我仍然不确定为什么未引用的 UTF-8 字符会在本地工作,但不适用于 GutHub。

于 2013-08-29T22:53:01.577 回答