Working with Templates

Templates define the structure of your content. They tell BCMS what fields each entry should have, and they help you organize different types of content in your project.

You can think of templates as content types - like Blog, Project, Author, Testimonial, or Product.


Creating and Editing a Template

To create a template, click on Create New Template.

create-new-template.png

Next, fill in the title, for example, "Blog."

It's recommended to use singular names for templates. For example, use "Blog" instead of "Blogs." This way, button labels will display "Add New Blog" instead of "Add New Blogs." However, the name you choose doesn't affect the functionality.

You can also add a description to each template, which is visible only inside the CMS. Descriptions are often used to outline internal processes, share resources, or explain the template’s purpose.

create-new-template-2.png

Adding Properties to a Template

To add properties to your template, select a property from the Property List on the right side and drag it into the template. Learn more about available properties.

Each template can include multiple fields. Click Add new field and choose the field type:

  • Sting – Plain text, for short text like titles or labels

  • Rich text – For content with formatting

  • Number – For prices, years, or any numeric data

  • Boolean – A true/false switch

  • Date – For publishing dates or events

  • Enumeration – For a predefined list of options

  • Media – For images, PDFs, or other files

  • Group pointer – A reusable set of fields

  • Entry pointer – Link to another entry (like an author or category)

adding-properties-to-a-template.gif

You can reorder fields, set them as required and allow multiple of them (array).


Use Entry pointers

Entry pointers let you connect entries from one template to another.

Example: A blog post can reference an Author entry from an Author template. This lets you fetch the full author data (name, photo, bio) when rendering the post.

To use it:

  1. Add a new field

  2. Choose Entry pointer

  3. Select the template you want to point to (like Author)

You can make the reference single or multiple. And required, if needed.


Add groups for reusable structures

Groups are shared sets of fields that you can reuse across templates and widgets. They help you keep your content model consistent.

Example group: SEO with fields:

  • Meta title (Plain text)

  • Meta description (Plain text)

  • Social image (Media)

To use a group in a template:

  1. Add a new field

  2. Choose Group pointer

  3. Select the group you’ve created

Manage template settings

In the template settings, you can:

  • Rename the template

  • Delete it

  • Change field labels

  • Add or remove fields

  • Set access permissions via API keys in project settings.

Template IDs are used in API calls. You can access them from the url.


Use the SDK to work with templates

To interact with templates in your code, use @thebcms/client. First, configure the client:

// client.ts
import { Client } from '@thebcms/client';
export const bcms = new Client(
  process.env.NEXT_PUBLIC_BCMS_ORG_ID!,
  process.env.NEXT_PUBLIC_BCMS_INSTANCE_ID!,
  {
    id: process.env.BCMS_API_KEY_ID!,
    secret: process.env.BCMS_API_KEY_SECRET!,
  },
  {
    injectSvg: true,
    useMemCache: true,
    enableSocket: false,
  },
);

Then, use the template handler:

// Get all templates
const templates = await bcms.template.getAll();

// Get one by ID
const template = await bcms.template.getById('templateId');

// Update a template
await bcms.template.update('templateId', {
  label: 'Updated name',
  desc: 'Updated description',
  // fields...
});

// Delete a template
await bcms.template.deleteById('templateId');

// Find where a template is used
await bcms.template.whereIsItUsed('templateId');

You can also find the full TemplateHandler implementation inside the BCMS client for reference.

Deleting a Template

To delete a template, click on Edit Template, choose Delete, and then confirm.

delete-a-template.gif

Next steps

  • Create a few templates for your content types

  • Add groups and widgets to improve structure

  • Try pointing entries between templates

  • Use the API or SDK to fetch and render structured content

Templates are the foundation of your content model - design them to match your real-world content needs.