musoNic80
musoNic80

Reputation: 3696

Using Liquid tags in a Jekyll page, not a layout

I want to use liquid tags in a page on a Jekyll site. I have used them successfully in layout files, but when I use them in a page they are not parsed by Liquid.

The page is in html format not Markdown. The page has valid YAML front-matter that is being successfully used by the layout file. Here's the code for the page that isn't parsing:

---
layout: default
title: Media
id: media
order: 2
---
<section id="photos">
<h2>Photographs</h2>
<div id="galleries">
    {% for set in site.flickr-sets %}
    <div class="gallery" data-set="{{ set }}"></div>
    {% endfor %}
</div>
</section>

Is there any obvious reason why this isn't working? I really need to be able to access the site global variable...

EDIT

It seems this issue isn't confined to just that page. I tried creating a new page and using some liquid syntax and got the same result. It's also any liquid syntax not just tags.

In the layout file that these pages use I include the content of the page using {{ page.content }} rather than just {{ content }}. Could that be relevant?

Upvotes: 7

Views: 2340

Answers (3)

Pankaj Phartiyal
Pankaj Phartiyal

Reputation: 1691

{{ content }} works and it's different than {{ page.content }}

{{ content }} it's parsing all liquid syntax :)

Hope that helps.

Upvotes: 4

Octavia Togami
Octavia Togami

Reputation: 4316

I know this may be a little late, but I dug up something called {{ page.output }} which is the rendered content of the page.

Upvotes: 2

musoNic80
musoNic80

Reputation: 3696

So it seems that the answer is that as I suspected. I tested the same code using a new layout file that just called {{ content }} and it rendered correctly. I'm assuming this means that when Jekyll builds it stores raw content in the page object. This is why pages with only html (or Markdown) were being rendered correctly, but any Liquid syntax was not being parsed.

Although this technically answers the question, I still haven't figured out how to solve my problem! It would be useful if there was some sort of filter I could add to {{ page.content }} to make it parse the Liquid syntax.

Upvotes: 3

Related Questions