if statement - Jekyll: Using Front Matter in Includes -
is possible use front matter in include. i've got include called image.html looks 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 about.md file looks this:
about.md
--- layout: page --- {% include image.html url="img.jpg" %} but reason, isn't recognising if layout statement. idea how work?
any appreciated. in advance!
update
full issue below:
if image.html include included on page, include needs have different layout, 2 encapsulating elements (container , sm-col-12). hope below makes bit more sense original question.
image.html
{% if include.size == 'full' , include.type != 'gif' %} <section class="image full-width"> <img src="{{ site.url }}/public/img/{{ include.name }}.{{ include.type }}"> </section> {% elsif layout == 'page' , 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" %}
from include file, still have page variable available.
in case, call page.layout :
<img src="{{ site.url }}/public/img/{{ include.url }}" {% if page.layout == 'page' %}class="page"{% endif %}>
Comments
Post a Comment