Bolt CMS: Using content types and relations

For a recent website project, I decided to use Bolt CMS, a free and open source content management system that is really powerful while being flexible and easy to use. One concept that I really liked was that of ContentTypes,

From the documentation —

Most websites will also have some form of news-like items, that are shown based on the date that they were published. Some other sites might have ‘book reviews’ or ‘event dates’ or even completely different content. All of these different types of content are called ContentTypes in Bolt, and you can add as many different ContentTypes as you need. Each ContentType is made up of Fields….

Our project was a dance company site, so we defined the following Content Types —

  1. Team Members.
  2. Videos
  3. Series (Collection of Videos)

In Bolt, all contenttypes are defined in contenttypes.yml. Here is what a sample contenttype looks like —

This is pretty similar to creating a database table with the fields title, description, frameUrl & type. The _recordtemplate\ indicates the twig template to be used when the page for this content type is rendered.

Relations

Your database has relations, so it would be amazing if your contenttypes had relations, right? Bolt supports creating Relationships between your content types and it is pretty straight forward. Here is the Series contenttype —

Now, as I mentioned earlier. Series is a collection of Videos. The key here is relations configuration. The works field maps series to the works contenttype.
Multiple — true means that multiple *works *records can be associated to one series record.

Here is how to list all related records in twig templates.

Here, the record refers to the current series.

You can read more about relationships here — https://docs.bolt.cm/3.4/contenttypes/relationships#

About relations in templates — https://docs.bolt.cm/3.4/contenttypes/relationships#relations-in-templates

This is the first project that I have developed with Bolt CMS and really liked working with it so far, the extension ecosystem looks healthy and the future looks promising.