如何将HTML标签放置在Jekyll帖子(经YAML编码)的开头,并阻止该HTML在最终输出中转义?我的内容(包括帖子标题)除使用首页语言外,还使用多种语言,并且这需要使用span lang="XX"
标签进行适当的标记,以用于屏幕阅读器和某些自动提取。但是,尝试编写以下内容:
---
layout: post
title: A post that says <span lang="fr">Bonjour</span> and <span lang="es">Hola</span>
---
导致这些标记转义的HTML输出结果:
<h1 class="post-title p-name" itemprop="name headline">A post that says <span lang="fr">Bonjour</span> and <span lang="es">Hola</span></h1>
因此,您正在使用的Jekyll的minima theme上,在escape
上已根据设计设置了escape
过滤器。
从文档中:
通过用转义序列替换字符来转义字符串(例如,可以在URL中使用该字符串)。它不会更改没有任何可转义的字符串。
来源:page.title
] >>
如果要显示https://shopify.github.io/liquid/filters/escape/,则应编辑文件__ layout / post.html
并删除此span
过滤器。此文件的第7行应如下所示
] >>espace
来源:
<h1 class="post-title p-name" itemprop="name headline">{{ page.title | escape }}</h1>
更改它,使其显示为
https://github.com/jekyll/minima/blob/49f6dce0727a2441f0b0c265b41b5efc7b042eb6/_layouts/post.html#L7然后您将达到预期的行为。