I was testing out a navbar in my Jekyll site and can’t get anything I write in the front matter to show up in it. Jekyll is showing no build errors.
I have a layout default.html, which I then include navigation.html in.
My navigation.html looks like this:
<div>
{% if site.data.samplelist.toc2[0] %}
{% for item in site.data.samplelist.toc2 %}
<h3>{{ item.title }}</h3>
{% if item.subfolderitems[0] %}
<ul>
{% for entry in item.subfolderitems %}
<li><a href="{{ entry.url }}">{{ entry.page }}</a>
{% if entry.subsubfolderitems[0] %}
<ul>
{% for subentry in entry.subsubfolderitems %}
<li><a href="{{ subentry.url }}">{{ subentry.page }}</a></li>
{% endfor %}
</ul>
{% endif %}
</li>
{% endfor %}
</ul>
{% endif %}
{% endfor %}
{% endif %}
</div>
Here is the front matter of the page I’m testing:
---
layout: docs
title: "The Difference between は and が"
toc2:
- title: Group 1
subfolderitems:
- page: Thing 1
url: /thing1.html
- page: Thing 2
url: /thing2.html
subsubfolderitems:
- page: Subthing 1
url: /subthing1.html
- page: Subthing 2
url: /subthing2.html
- page: Thing 3
url: /thing3.html
- title: Group 2
subfolderitems:
- page: Piece 1
url: /piece1.html
- page: Piece 2
url: /piece2.html
- page: Piece 3
url: /piece3.html
subsubfolderitems:
- page: Subpiece 1
url: /subpiece1.html
- page: Subpiece2
url: /subpiece2.html
- title: Group 3
subfolderitems:
- page: Widget 1
url: /widget1.html
subsubfolderitems:
- page: Subwidget 1
url: /subwidget1.html
- page: Subwidget 2
url: /subwidget2.html
- page: Widget 2
url: /widget2.html
- page: Widget 3
url: /widget3.html
---
The front matter is an example from the Jekyll doc website. But after I build nothing shows up in the navigation div.
Even if I do something simple like have food: Pizza
in my front matter and then have <h1>{{ page.food }}</h1>
on my default layout, nothing is returned. It only returns something if I paste <h1>{{ page.food }}</h1>
on the .md page with the custom front matter directly.
Siena is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.