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