lnxd
lnxd

Reputation: 39

Include another page with Jekyll without displaying Front Matter

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.

Upvotes: 3

Views: 447

Answers (1)

&#230;ndr&#252;k
&#230;ndr&#252;k

Reputation: 788

A fragile hack:

{% capture source %}{% include_relative included.html %}{% endcapture %}
{{ source | split: "---" | last }}

Just don’t use --- anywhere in the included document. :)

Upvotes: 4

Related Questions