Skip to content

Collections within collections - are they possible? #1735

Answered by pdehaan
rachaelfurnbullard asked this question in Q&A
Discussion options

You must be logged in to vote

I definitely think it's possible, but might be a bit tricky based on how your folders and variables are named.

Here's my _data/venues.json file:

[
  { "name": "Venue 1", "key": "venue1" },
  { "name": "Venue 2", "key": "venue2" }
]

And my _data/venue/venue1.json (and venue2.json) files look roughly like this:

{
  "name": "Venue 1",
  "address": "100 Main St, City, State, Country"
}

This is where is starts to get a bit tricky...
Here's my venue-page.njk template:

---
title: Venues
pagination:
  data: venues
  size: 1
  alias: _venue
permalink: "/{{ _venue.name | slug }}/"
---

{# `venue` here refers to /_data/venue/* directory. #}
{% set $venue = venue[_venue.key] %}

<p>name={{ $venue.name 

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@rachaelfurnbullard
Comment options

@rachaelfurnbullard
Comment options

Answer selected by rachaelfurnbullard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants