使用 Jekyll 包含另一个页面而不显示 Front Matter
我正在尝试将 index.html
的输出克隆到另一个页面 thanks.html
中。它正在工作,但无论我尝试什么,我最终都会得到 ---layout: default title: example ---
渲染(来自 index.html
的 Front Matter)文件开始的地方。
我尝试过:
---
layout: default
thanks: true
---
{% capture main %}{% include_relative /index.html %}{% endcapture %}
{{ main }}
并且:
---
layout: default
thanks: true
---
{% include_relative /index.html %} <!-- Same problem with just 'include' -->
但我得到了相同的结果。
如果我删除行 layout: default
它可以工作,但正如预期的那样,我不再有页眉或页脚。我也可以使用包含来使其工作,但这会导致具有不同行的页面出现大量重复。
如果相关的话,我正在通过 docker 运行 Jekyll 版本 4.2.2,并且我的 _config.yml
中没有设置插件。
I'm trying to clone the output of index.html
in another page, thanks.html
. It's working, but no matter what I try I end up with --- layout: default title: example ---
rendered (from index.html
's Front Matter) where the file starts.
I've tried:
---
layout: default
thanks: true
---
{% capture main %}{% include_relative /index.html %}{% endcapture %}
{{ main }}
And:
---
layout: default
thanks: true
---
{% include_relative /index.html %} <!-- Same problem with just 'include' -->
But I get the same result.
If I drop the line layout: default
it works, but as expected I don't have a header or footer anymore. I can also get it to work using includes but this makes for a lot of duplication for a page with a single line that's different.
In case it's relevant, I'm running Jekyll version 4.2.2 via docker, and there are no plugins set in my _config.yml
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一个脆弱的黑客:
只是不要在包含的文档中的任何地方使用
---
。 :)A fragile hack:
Just don’t use
---
anywhere in the included document. :)