5
votes

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?

3
What is the source of flickr-sets? Is that a directory of pages that you want to loop through like posts?Sean Redmond
No. It's an array of Flickr set ids stored in my config.yaml file.musoNic80
What's the output? Is it printing the Liquid tags as part of the HTML?agarie
Yes. It prints them in double quotes. It also renders properly the HTML between the tags rather than print it raw.musoNic80
I wondered if the word "set" was not allowed for some reason, but it doesn't make any difference which word I choose.musoNic80

3 Answers

4
votes

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

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

Hope that helps.

3
votes

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.

2
votes

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