Is it possible to use front matter in an include. I've got an include called image.html
that looks like this.
image.html
{% if layout == 'page' %}
<img src="{{ site.url }}/public/img/{{ include.url }}" class="page">
{% else %}
<img src="{{ site.url }}/public/img/{{ include.url }}">
{% endif %}
And an about.md
file that looks like this:
about.md
---
layout: page
---
{% include image.html url="img.jpg" %}
But for some reason, it isn't recognising the if layout
statement. Any idea how to get this to work?
Any help is appreciated. Thanks in advance!
UPDATE
Full issue below:
If the image.html
include is included on a page, the include needs to have a completely different layout, with two encapsulating elements (container
and sm-col-12
). Hope the below makes a bit more sense than my original question.
image.html
{% if include.size == 'full' and include.type != 'gif' %}
<section class="image full-width">
<img src="{{ site.url }}/public/img/{{ include.name }}.{{ include.type }}">
</section>
{% elsif layout == 'page' and include.type != 'gif' %}
<div class="container">
<div class="sm-col-12">
<section class="image">
<img src="{{ site.url }}/public/img/{{ include.name }}.{{ include.type }}">
</section>
</div>
</div>
{% elsif include.type != 'gif' %}
...
{% else %}
...
{% endif %}
about.md
---
layout: page
---
{% include image.html name="zifferblatt" type="jpg" %}