Liquid Tags Not Working in Markdown Files in Non-Post Subdirectory

Liquid tags like {{ site.baseurl }} not rendering in non-post subdirectory (called “momentum_content”) markdown. Non-rendered, raw Liquid tags shown here: https://kimardenmiller.github.io/Momentum/test/

Liquid tags seem to work fine in markdown within _posts.

jekll build --verbose says it’s rendering the files:

Rendering: momentum_content/test.md
Pre-Render Hooks: momentum_content/test.md
Rendering Liquid: momentum_content/test.md
Rendering Markup: momentum_content/test.md
Rendering Layout: momentum_content/test.md

… but a little differently than it renders posts, where “Rendering Liquid” is not listed:

Rendering: _posts/2018-04-28-rebuilding.markdown
Pre-Render Hooks: _posts/2018-04-28-rebuilding.markdown
Rendering Markup: _posts/2018-04-28-rebuilding.markdown
Rendering Layout: _posts/2018-04-28-rebuilding.markdown
Layout source: site

Have tried using collections, but makes no difference:

collections:
momentum_content:
output: true

Full source at: GitHub - kimardenmiller/momentum

I believe the problem is your post.html layout and this line. You don’t need page.content nor do you need the Markdownify filter… just plain ole {{ content }} will do the trick.

You’re essentially applying it twice which is why you’re getting the unrendered Liquid. I just cloned your repo and replaced {{page.content | markdownify }} with {{ content }} and the Liquid tags in your test.md file output as expected.

What about in a context where I’m rendering the content of a different page?

That depends on how you’re pulling in content from a different page. Usually that’s done via a for loop on an object. In that case you prepend content with whatever you named the items in the loop to e.g. foo.content

Example

{% for foo in site.posts %}
  {{ foo.title }}
  {{ foo.content }}
{% endfor %}

Right, but in that context, specifically in an html include, I’ve had the problem before that the markdown didn’t render and it required a | markdownify… which now seems to have escaped the liquid tags :pensive: It seems I’m stretching Jekyll to its limit having an include inside page content inside an include inside page content :laughing:

Includes are a different beast. They depend on the file extension used as well. If you have a .html include it’s going to need the markdownify filter. But if it’s .md then I believe it will parse the text as Markdown without the filter.

Though that’s likely not what you want either since you have HTML in the include and you’ll find all sorts of goofiness changing the include’s extension to .md since indents will be interpreted as code blocks and your HTML markup will get mangled.