# Automotive Makes and Models: a case of nested collections and permalinks

**URL:** <https://talk.jekyllrb.com/t/automotive-makes-and-models-a-case-of-nested-collections-and-permalinks/7825>\
**Category:** Help\
**Created:** [November 20, 2022, 11:34pm UTC](https://talk.jekyllrb.com/t/automotive-makes-and-models-a-case-of-nested-collections-and-permalinks/7825 "2022-11-20T23:34:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![luis.carmona](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/luis.carmona/32/4995_2.png) [@luis.carmona](https://talk.jekyllrb.com/u/luis.carmona)\
**Post date:** [November 20, 2022, 11:34pm UTC](https://talk.jekyllrb.com/t/automotive-makes-and-models-a-case-of-nested-collections-and-permalinks/7825/1 "2022-11-20T23:34:05Z")

</div>

Hello everyone!

I’m trying to put together a Jekyll website which has automotive objects of Makes and Models, which I think means I need to have nested collections.

For this, I started by having this structured data folder system:

```auto
_data
    _makes
        audi.md
        citroen.md
        ...
    _models
        berlingo.md
        c1.md
        c3.md
        c3-aircross.md
        c4.md
        c4-aircross.md
        ...

```

Here’s how my `citroen.md` looks like:

```auto
---
title: Citroen
slug: citroen
description: "Citroen cars offer something different to most rivals with a focus on innovative design, excellent comfort and superb value for money. We have a range of high-quality used Citroen cars for you to purchase or finance, including the C3, C4 Cactus and C1."
popular: true
---

```

Here’s how my `c3.md` looks like, with a property called `make` that I’m using to try and create the relationship between the two objects:

```auto
---
title: C3
slug: c3
description: "The Citroen C3 is a hatchback that's inexpensive to run and comfortable to drive. Its interior is colourful, quirky and feels well made. It also has a bigger boot than many key rivals."
popular: true
make: citroen
---

```

Not sure if this is the best way to do this, but it’s kind of working because I can list all of a make’s models like this:

```auto
{% assign makeModels = site.models | where: 'make', make.slug %}
{% for model in makeModels %}
<a href="{{ model.url }}">{{ model.title }}</a>
{% endfor %}

```

Also, collections on my `_config.yml` look like this:

```auto
collections_dir: _data
collections:
  makes:
    output: true
    permalink: /:collection/:name
  models:
    output: true
    permalink: /makes/:make/:collection/:name

defaults:
  - scope:
      path: ""
      type: "makes"
    values:
      layout: "make"
  - scope:
      path: ""
      type: "models"
    values:
      layout: "model"
  - scope:
      path: ""
    values:
      layout: "default"

```

and that’s when things stop working because apparently I can’t do this:

```auto
permalink: /makes/:make/:collection/:name

```

because it’s throwing this error:

```auto
Liquid Exception: The URL template doesn't have make keys. Check your permalink template! in _layouts/make.html

```

What I want do is make sure that I have the list of makes on this permalink:

```auto
/makes/

```

the page for a particular make (e.g. Citroen) on this permalink:

```auto
/make/citroen

```

the page for a particular model (e.g. C3) as a child of that make, like so:

```auto
/make/citroen/model/c3

```

I’m aware that the problem looks like it’s that `:make` in the permalink, but how could I have the make in the parmalink then? Help?
