Jekyll collections or category choice for catalogue website?

239 Views Asked by At

I'm trying to build a catalogue like a website with vintage processors in Jekyll. They are structured like so: Manufacturer/type/processor.

For example: AMD / K6 / K6-166ALR

I am a little puzzled on how to do this. K6-166ALR.html would be the file with the processor details but should I use categories or collections here? Could you please point me in the right direction?

1

There are 1 best solutions below

2
On BEST ANSWER

If I've understood well your question, you could use the following solution:

  • Three collections: manufacturers, types and processors.
  • Layouts, at least, for manufacturers and types.
  • In each type, put the manufacturer in the front matter.
  • In each processor, put the type in the front matter.

The config file would look like this:

_config.yml

# rest of the file
collections:
    manufacturers:
        output: true
    types:
        output: true
    processors:
        output: true

And the layouts should be like this:

_layouts/manufacturer.html

---
layout: default
---
<!-- Details of the manufacturer -->
{% page.content %}

<!-- Types related to the manufacturer -->
<ul>
{% for type in site.types %}
{% if type.manufacturer == page.name %}
    <li><a href="{{ page.url }}">{{ page.name }}</a>
{% endif %}
{% endfor %}
</ul>

_layouts/type.html

---
layout: default
---
<!-- Details of the type -->
{% page.content %}

<!-- Processors related to the type -->
<ul>
{% for processor in site.processors %}
{% if processor.type == page.name %}
    <li><a href="{{ page.url }}">{{ page.name }}</a>
{% endif %}
{% endfor %}
</ul>

This way, some examples of your content could be:

_manufacturers/AMD.html

---
name: AMD
---
Information about AMD.

_types/K6.html

---
name: K6
manufacturer: AMD
---
Information about AMD manufactured K6.

_processors/K6-166ALR.html

---
name: K6-166ALR
type: K6
---
Information about K6-166ALR.

You would only need a handmade page to display the manufacturers. The rest would be generated from the info of your collections.

I hope it helps, comment if something's not clear or I didn't understand your question.