Content model · Lesson 3 of 15 · 15 min
Model the content, not the page
Design three content types that link to each other, and let validations do your quality checks.
This is the lesson that matters most. A good content model makes everything after it easy. A bad one follows you around for years.
The rule: model the content, not the page. A Lesson has a title, a body, and an author. It doesn’t have a “sidebar text” or a “hero color”. Those belong to the website, and the website will change.
The model
Course ──has many──▶ Lesson ──has one──▶ Author
| Content type | Fields |
|---|---|
| Author | Name, Role, Photo |
| Lesson | Title, Slug, Summary, Minutes, Body, Author |
| Course | Title, Slug, Summary, Level, Lessons |
1. Create Author
Go to Content model → Create content type. Name it Author. Contentful fills in the API identifier author. That identifier is what your code will use.
Add these fields:
| Name | Field type | Settings |
|---|---|---|
| Name | Text, short | Required. Tick “This field represents the Entry title”. |
| Role | Text, short | |
| Photo | Media, one file |
Click Save.
2. Create Lesson
| Name | Field type | Settings |
|---|---|---|
| Title | Text, short | Required. Entry title. |
| Slug | Text, short | Required. Unique field. Appearance: Slug. |
| Summary | Text, short | |
| Minutes | Number, integer | |
| Body | Rich text | |
| Author | Reference, one | Accept only specified entry type: Author |
Each field gets a field ID made from its name: title, slug, summary, minutes, body, author. Check them as you go. Your code depends on these exact IDs.
3. Create Course
| Name | Field type | Settings |
|---|---|---|
| Title | Text, short | Required. Entry title. |
| Slug | Text, short | Required. Unique field. Appearance: Slug. |
| Summary | Text, short | |
| Level | Text, short | Accept only specified values: Beginner, Intermediate, Advanced. Appearance: Dropdown. |
| Lessons | Reference, many | Accept only specified entry type: Lesson |
Why it’s built this way
- Slug is unique and required. The slug becomes the URL. Two lessons with the same slug would fight over one page. The validation makes that impossible.
- Level is a fixed list. Editors pick from a dropdown, so you never get “beginner”, “Beginner “, and “Begginer” in the same site.
- References limit their type. The Author field only accepts Authors. Nobody can link a Course there by mistake.
- Course holds the list of Lessons. The order of that list is the order of the course. Editors drag to reorder. No “order” number to maintain.
- Author is its own type. Change a job title once and every lesson by that author updates.