When building the data structure of an application, you need to create collections to manage your blog posts, your products, or any content that will be repeated. This feature has been available in Strapi for quite a long time.
But managing content that will have only one instance in your project is highly requested by Strapi users - for example, your menu, a static page, or a footer. Managing Single Types is essential, and this is why we are delighted to announce today the release of Strapi beta.19, including the Single Types feature.
Let's explain what this feature is about, and how to use it with a step-by-step typical user journey, and you'll be able to install and play with it for your project!
But first things first, we would like to congratulate community members that contributed so shout out to @robinv85, @MurzNN for their contributions in this release!
Single Types is one of these features that facilitates content management. They are handy for managing content like a homepage, an About us page, or any other content not part of a collection. It is also helpful for managing global settings, like SEO settings.
Think of all the specific parts of your app that you need to set up only once. Your menu, your footer. This feature is made for them. Let's see how Single Types are managed in Strapi and how you can take advantage of this new feature for your projects.
In this example, we are going to create an About Us page containing a hero section with a cover image, a content section with texts and pictures, and a footer looking like the Foodadvisor About us page: https://foodadvisor.strapi.io
Creating a single type is as easy as creating a collection type.
To do so, you must navigate to the Content-Type Builder and create a Single Type from the sub-menu. So let's go ahead and create our About-us Single Type. We need to add the following fields to match our example page on Foodadvisor:
A Single Type section has now appeared, containing the Single Type About. The two sections allow differentiating Single Types from Collections Types for a more comfortable authoring experience.
You probably also noticed that when we named the Single Type, the following field in the modal was auto-filled with content. The other new feature in this release is the UID field.
The UID field is a unique identifier that can be used to identify your type. The most common use case is to create SEO-friendly website URLs.
This field requires entering a lowercase, space-free unique id such as about-us. But don't worry about errors; we got your back: the field will first auto-populate with the name you chose for the Single Type, with all spaces replaced with hyphens. But you can also decide to manually add a UID field in your Single Type and link it to the field of your choice.
In our example, we will add a UID field Slug in the Single Type About, and link it with the Title field we already created. That way, if the Title of the page is actually The Team, we will be able to have an SEO-friendly URL looking like this: https://foodadvisor.strapi.io
Each Single Type that contains a UID field must have a unique value for this field. This ensures that all your URLs are unique.
As engineers, when you build the content model of an application, you are determining the content author experience for months or years. So each page or content types must be easy to access and configured as it should. This is why in Strapi, you can set the view and change the order of the fields as you want.
If you are familiar with Strapi, you probably already know this, as it is strictly similar to the Collection Types configuration page.
Single Types can only have one-to-one or one-to-many relations with Collection Types, as they are Single Types. They can easily be switched to Collection Types (by clicking on the editing pen next to the Single Type name).
Collections Types can also be switched to Single Types, only if they have no relational incompatibility (like a many-to-many relation field).
Single Types can be switched to Collections Types and the other way around as long as they have no relations set with other Content Types.
In our example, we created a Collection Type Blog Post that contains a Relation field many-to-many. Switching it to a Single Type doesn't work unless we change the relation field value to one-to-one.
A fully detailed migration guide is available. The changelog is also available here.
If you are new to Strapi, give it a try!
Take a look at the Getting Started guide to jump on board, or get started with the following command line:
1yarn create strapi-app my-app
Check out our public product roadmap to see what features we'll work on next.
Don't see a feature you'd like in the backlog? Feel free to submit new feature requests or even better, start contributing to Strapi on GitHub. All contributions and users are welcome!
Pierre created Strapi with Aurélien and Jim back in 2015. He's a strong believer in open-source, remote and people-first organizations. You can also find him regularly windsurfing or mountain-biking!