You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm having a bug with Jekyll. I try to display a list, and the items in this list will display depending on if a variable is set or not.
For this I'm using the collections, where in every file the different variables of the component are set. But for some files some variables don't exist, so I'd like them not to display. This is my code at the moment, but it's just not displaying anything.
In the list
{% for icon in site.icons %}
{% if unicode_ultralight %}
<li>
<h2>{{ icon.title }}</h2>
<p>{{ icon.unicode_ultralight }}</p>
</li>
{% endif %}
{% endfor %}
In the icon.md
title: user
unicode_ultralight: 123
When I try to write {% if unicode_ultralight != empty %} it displays the list, but if I delete the variable it still displays the icon.
I tried all the solutions here #223 but no luck...
Thanks for your answers!
OS: macOS Mojave
Jekyll Version 3.8.6
The text was updated successfully, but these errors were encountered:
The issue is with how you're using the front matter variable. unicode_ultralight is not a valid Liquid variable unless you have previously defined it using the assign tag or capture tag.
The correct syntax to use a front matter key is to send the key to the concerned document i.e. icon.unicode_ultralight. Therefore, your snippet should be:
{% for icon in site.icons %}
{% if icon.unicode_ultralight %}
<li>
<h2>{{ icon.title }}</h2>
<p>{{ icon.unicode_ultralight }}</p>
</li>
{% endif %}
{% endfor %}
Hi everyone,
I'm having a bug with Jekyll. I try to display a list, and the items in this list will display depending on if a variable is set or not.
For this I'm using the collections, where in every file the different variables of the component are set. But for some files some variables don't exist, so I'd like them not to display. This is my code at the moment, but it's just not displaying anything.
In the list
In the icon.md
When I try to write
{% if unicode_ultralight != empty %}
it displays the list, but if I delete the variable it still displays the icon.I tried all the solutions here #223 but no luck...
Thanks for your answers!
OS: macOS Mojave
Jekyll Version 3.8.6
The text was updated successfully, but these errors were encountered: