Using Liquid Tags on a Jekyll Page, Not a Layout

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

The page is in html format, not Markdown. The page has a valid YAML front element that is successfully used by the layout file. Here is the page code that is not being processed:

--- 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 an obvious reason why this does not work? I really need to have access to the global site variable ...

EDIT

This problem does not seem to be limited to just this page. I tried to create a new page and use some kind of liquid syntax and got the same result. It is also any liquid syntax, not just tags.

In the layout file that these pages use, I include the contents of the page using {{ page.content }} , not just {{ content }} . Could this be relevant?

+4
source share
3 answers

So it seems that the answer is that, as I suspected. I tested the same code using the new layout file I just named {{ content }} and it displayed correctly. I assume this means that when Jekyll creates it, it stores the raw content in the page object. This is why pages with only html (or Markdown) are processed correctly, but any Liquid syntax is not parsed.

Although this technically answers the question, I still have not figured out how to solve my problem! It would be useful if there was some kind of filter that I could add to {{ page.content }} to parse the syntax of Liquid.

+2
source

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

+1
source

{{ content }} works and it is different from {{ page.content }}

{{ content }} it parses the entire fluid syntax :)

Hope this helps.

0
source

Source: https://habr.com/ru/post/1493272/


All Articles