Reputation: 29
I have used this answer https://stackoverflow.com/a/34783367/1279102; but am unable to work out how to use a variable folder.
{% for image in site.static_files %}
{% if image.path contains '{{ page.gallery }}' %}
<img src="{{ site.baseurl }}{{ image.path }}" alt="image" />
{% endif %}
{% endfor %}
I have added 'gallery' to the front matter of my post. I have tried using the absolute path, and the relative path.
It appears that no matter how you add the {{ page.gallery }}
variable in the if
portion, it is not changed to the corrected value.
What am I missing?
Upvotes: 0
Views: 349
Reputation: 5444
you can't interpolate within liquid tags. assign the value to the variable beforehand.
{% capture ipath %}{{ page.gallery }}{% endcapture %}
{% for image in site.static_files %}
{% if image.path contains ipath %}
<img src="{{ site.baseurl }}{{ image.path }}" alt="image" />
{% endif %}
{% endfor %}
Upvotes: 2