Unit 04 · lesson
Collections and Custom Content Types
Posts solve date-oriented content.
Projects are usually not date-oriented in the same way.
That is where collections become useful.
Collection mental model
A collection is a named group of related Jekyll documents.
The official tutorial describes collections as similar to posts except their content does not need to be grouped by date.
For a portfolio:
_projects/
line-follower.md
network-dashboard.md
can represent a projects collection.
Configure it
In _config.yml:
collections:
projects:
output: true
Configuration changes commonly require restarting the Jekyll server so the new settings are loaded.
Why this may beat _data
Each project document can have:
- front matter;
- Markdown body;
- its own generated page when output is enabled;
- a shared layout;
- collection metadata.
That fits a case study better than a giant YAML string.
Why it may beat posts
A project may have a creation date, but its identity is "project," not "entry published on Tuesday."
Checkpoint
Compare one project in _data/projects.yml with the collection model you are about to build.
List what becomes easier and what becomes more complex.