⚠️ This lesson is retired and might contain outdated information.

Creating a Collection Type for Posts in Strapi

Daniel Phiri
InstructorDaniel Phiri
Share this video with your friends

Social Share Links

Send Tweet

Now that we've created our project, we need to set up our project to hold data. We will create a post collection type with all of the fields we want to have on our posts. With that created, we'll create a couple of mock posts for testing.

Instructor: [0:02] Inside the Strapi dashboard, we'll go to our Content-Type Builder plugin. We'll use our Content-Type Builder plugin to create a collection type. [0:09] Collection type is a collection of related fields. We'll click, "Create new collection type," and we'll name our collection type, "Post."

[0:18] To represent the post in the blog that we will build, click, "Continue," and we'll start out with a text field called, "Title." We'll add another field, this time a date field, and we'll call this, "Date." We'll choose the format date.

[0:38] We'll add a rich text field and name this, "Body," so we can type in Markdown. We'll add another text field and call this, "Author." Then, we'll add a UID for our slug.

[1:00] We'll attach this field to our title field so that it's auto-generated whenever we fill that in. Click, "Finish." We'll save our collection type and wait for our server to restart.

[1:12] Now that our server has restarted, we'll go to our content manager to add data to our collection type. Click, "Post," and then, "Create new entry."

[1:23] As a title, we'll add "Exactly What You Need." We'll pick the date of 9th August. We'll add a body with Markdown, and then create an author called Humpty Dumpty. Then, we'll regenerate our slug, "Exactly What You Need."

[1:51] Perfect. We'll save this and then publish. We'll go to our collection type again and duplicate this. We'll change "Exactly What You Need" to "Maybe Exactly What You Need," keep this the same and say, "Duplicate item" at the top, and then give this a title.

[2:18] Then, regenerate our slug, save this, and publish. We go back to our post collection type. We have two published entries. That is how you create a collection type in Strapi, and add data to it.