allBlogsList

Defining Custom Schema in Content Hub

Introduction

Content Hub acts as a home base for all your disparate content, as well as a platform that helps streamline, speed up, and simplify every part of a marketer’s job — all in one solution. Content Hun includes many things, of which one the most interesting for us were it is easy to define and change schema management, which worked very well in the number of Enterprise implementations. Entity schema defines the structure of data objects and relationships between them in Content Hub. This post was written to serve as a high-level, getting started guide on how to define and update custom data schema in Content Hub

Out of the Box schema

Sitecore Content Hub offers an out-of-the-box (OOTB) schema revolving around the Asset definition and, depending on selected install options, Content, and Products. This document describes OOTB Asset-related schema definitions. Assets are usually digital assets, such as images, videos, or, in some cases, document files. This part of the OOTB schema is well-defined and works well as is or with minimal changes. The following sections describe how to create custom schema definitions for kinds of data not covered by OOTB schema, e.g. company products, content pages, business records, ships, hotels, promotions, ads, etc.

Defining Custom Schema Entities

The process of defining the custom schema definitions in Content Hub is somewhat similar to the process of defining the database schema or, say, custom class definitions in an object-oriented programming language. The Entity schema definition in Content Hub contains a set of fields, which can hold a value of a given data type or be a relation, connecting a given entity to one or more entities of a different kind, which allows connecting different entities to each other to form a schema, much like a database schema in a relational database or an object hierarchy in an object-oriented program.

To start managing the schema in Content Hub navigate to Admin/Management page and click on the "Schema" link. The schema page allows changing an existing Entity definition by clicking "" on the right side of an Entity and then choosing "Edit"

custom

The schema page allows to create a new definition: click on "New Definition", give it a name, and then click on "Create" custom

Entity fields are grouped together in Groups, there's actually no way to add a field to an Entity without assigning it to a group, so continuing with the "Test" Entity sample above, I'll create "Sample Group" by clicking "New Group" button and then filling in the Name and optional Label fields like so: custom

Once the newly created group is selected, new properties, relations, and taxonomies can be added to it. Click on "New Member" and then choose the kind of Field/Member to be added to the Entity definition custom

custom

  • "Property" is a field, meant to hold a value of a given data type. For details on available property types and creation options please refer to this document. custom

  • "Relation" allows associating different kinds of Entities to each other, similarly to foreign keys in a relational database. On the following screenshot, my Test entity has added a "TestToAssets" relation, allowing to create a link between the new Test Entity and one or more Assets (of type M.Asset). This page provides more details on adding a relation. custom

  • "Taxonomy" is a special kind of Entity in Content Hub, which enables hierarchical structure on its Entities, more details on taxonomies can be found in Content Hub documentation on taxonomies. Adding taxonomy members to schema definition is quite similar to adding relations. More details on adding taxonomies can be found here custom

  • This is how my Test entity definition looks like after adding three different kinds of fields, described above. New or updated Entity definition must be published in order to become available in the system, clicking on "Publish" triggers schema validation and then publishing new or updated Entity definition. One thing to keep in mind when updating existing entities is that removing or updating entity fields may lead to data loss if instances of a given Entity type already exist in the system. custom

Managing Entity Data

With new Entity definition in place, entity records can be managed from the "Entities" page, which can be reached right from the Entity definition page or selected from the list of entities under Admin/Management -> Entities page custom custom custom

Content Hub automatically adds needed components to the entity details page, allowing to immediately start creating and editing entities of any type. The following screenshot is showing how values can be added to the above-defined custom entity using such OOTB Entity details page. Content Hub allows to define custom entity pages, which turns it into a really powerful no-code solution, allowing to definition schema and user-friendly data management interfaces.

custom