Ad
How Do You Pass Site.data To Includes Within Includes In Jekyll?
I have a snippet of code I include whenever I need to display a gallery.
<!-- _includes/gallery.md -->
{% assign items = {{include.data}} %}
{% for item in items -%}
{% assign src = item.path | prepend: "/assets/images/" | relative_url %}
[{:.gallery-{{items.size}}}]({{src}})
{%- endfor %}
{:.text-center}
I can pass site.data
to populate the gallery.
{% include gallery.md data = site.data.index.themes %}
I have a template page which needs to display a gallery. I want to pass in site.data
as well.
<!-- _includes/create-new.md -->
Create a new {{include.type}}:
{% include gallery.md data = {{include.site_data}} %}
But when I try to pass in site.data
to the template page, I get an error.
{% include create-new.md type = "layout" site_data = site.data.index.layouts %}
How do you pass site.data
to includes within includes?
Ad
Answer
Simply pass it like any other data irrespective of whether nested within another include tag:
<!-- _includes/create-new.md -->
Create a new {{ include.type }}:
{% include gallery.md data = include.site_data %}
Ad
source: stackoverflow.com
Related Questions
- → GitHub Pages and Jekyll content duplication and SEO issues
- → Error in Liquid templating when including non-english (UTF-8) filenamed files
- → Liquid shorthands?
- → Jekyll - creating a gallery with front matter data
- → How to display bootstrap carousel with 3 items per slide using Liquid Shopify
- → how to use react jsx templates in static site generator like jekyll
- → metalsmith static site generator (with react jsx)
- → Jekyll Cannot Be Deployed on Manjaro Linux - Sass-Listen-4.0.0 Cannot Be Installed On Deployment (GitLab, Netlify)
- → How do I get HTML rendered as markdown via GitHub Pages?
- → What is the best way to move the context of a git repo?
- → Changing logo.svg file on Jekyll GitHub (reducing pixel size does not appear to make change)
- → Getting an Git related Error when trying to build or serve with new theme
- → Uncaught TypeError: Cannot read property 'addEventListener' of null in JavaScript webshare api
Ad