David Silva Smith
David Silva Smith

Reputation: 11716

Can I use markdown in Jekyll 1.5.1 layouts?

In Jekyll 1.5.1 my layouts are being parsed, but markdown is being ignored.

Is there a way to work around this?

Here is my post.md layout

---
layout: default
---
<h2>{{ page.title }}</h2>
<p class="meta"></p>

<div class="post">
{{ content }}
</div>

* first
* second
* third

# hi

The page.title, content, and the layout are picked up, so I know Jekyll is parsing the file.

I expect the first second and third to be in a list and I expect the hi to be an h1, but they don't get picked up by markdown, while other files like test.md do (in fact test.md even uses this layout).

Upvotes: 4

Views: 164

Answers (2)

David Silva Smith
David Silva Smith

Reputation: 11716

I wanted to include a submenu for a particular sub directory in my default layout. I got it to work like this:

{% if page.url contains '/for-citizens/'' %}
  {% capture submenu %}{% include for-citizens-menu.md%}{% endcapture %}
  <div class="navbar-collapse collapse">
    <ul id="navList" class="nav navbar-nav">
      {{ submenu | markdownify }}
    </ul>
  </div>
{% endif %}

Upvotes: 1

Christian Specht
Christian Specht

Reputation: 36451

I can't find any "official" source that says so, but from my own experience, I think that Jekyll layout files are supposed to be HTML only.

There's nothing in the docs that explicitly states this, but all the examples in every Jekyll tutorial I ever read are using .html files as layout files.
However, I admit it's strange that Jekyll recognizes your .md file as a layout file, but doesn't parse the Markdown.

So I'd say: go the path of least resistance.
Just change the name of the file to .html, and replace the Markdown inside by HTML, and you're done.

It's a layout file, it's not supposed to be changed that often.

Upvotes: 1

Related Questions