In Jekyll, I can pass the link to the site dataset in front of

I have a layout used for the home page for different sections on my Jekyll site. On each of these pages, I would like to have links to each element of the section, the details of which are stored in the YAML file in the site directory _data. My goal is to have the name of the site data variable in the main section of the section and pass this to the layout for rendering. For instance:

Front Matter Page

---
sectionItems: site.data.sectionItems.awesomeSectionItems
---

... which is passed to the layout of the main section ...

Splitting the main layout

{% for item in page.sectionItems %}
    // Work with section item...
{% endfor %}

Unfortunately, when the site starts, nothing appears. How should I do it? I also tried turning it on, but this also does not work. I would like to avoid adding a for loop to each page, plus I would like the links to appear below the main content section.

+4
source share
1 answer

You cannot use variables in front. You will have to use a content variable, for example {% assign sectionItems = site.data.sectionItems.awesomeSectionItems %}, and then loop with {% for item in sectionItems %}.

+2
source

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


All Articles