Data Model Reference
Reference for the Built.js Data Model
NOTE: Data is compiled into .built/data.json
by running npx create-built-app update
The Built.js data model is represented in a theme or plugin Next.js project by JSON data files in the public/data
directory of the project.
Data files contain JSON data used for configuration of theme or plugin's pages, sections, plugins and more. They are kept in public/data
.
These are the folders and files that you will find in this directory for a theme:
For a plugin, you will find a plugin.json
file instead of theme.json
. See App data
Here's a summary of how they work together:
global.json
- Contains site-wide settings like site name and logo.
theme.json
- Defines the theme's metadata, including namespace, title, description
- Lists required plugins and dependencies
- Specifies design system
sections.json
- Defines reusable page sections (e.g., homeSeo, homeLanding, header, footer)
- Each section has:
- Configuration data
- Template assignments
- Type (head, body, or layout)
- Collection references
templates.json
- Defines available templates for different components
- Includes metadata like category, namespace, and description
- References to actual component implementations
layout.json
- Defines the global layout structure
- Specifies order of sections (header, content, footer)
pages.json
- Lists all pages in the site
modules.json
and module-pages.json
- Defines modular components that can be used across pages
- Maps modules to specific pages and positions
schemas/ directory
- Contains schema definitions for sections, content types, and global settings
- Provides validation and structure for the content
- plugins/ directory
- Contains plugin-specific data configurations
The structure follows a modular, component-based architecture where:
- Global settings define site-wide configurations
- Sections are reusable components
- Templates define the visual implementation
- Modules provide functionality
- Everything is tied together through pages and layouts
This setup allows for:
- Easy theme customization
- Reusable components
- Flexible page layouts
- Plugin extensibility
- Clear separation of concerns between content, layout, and functionality
This is a more detailed breakdown of the data files:
Schema files
These files, located in public/data/schemas
, create the definitions that will be used for Sanity schemas when the site is built.
Content Type schema
A Content Type's schema is defined in public/data/schemas/content-types.json
like this:
Field | Type | Description |
---|---|---|
name | String | Camel case identifier |
title | String | A succinct label for the Content Type |
dataPosition | Number | This is used during the setup process for a site. It determines the order of creation for Sanity schemas and is used when you need to create a schema before or after another due to the relationship. |
fields | Object | Schema fields for Content Type |
See Content Type data types for the data types that can be used for Content Type fields.
Example
https://github.com/richjava/corporate-basic/blob/main/public/data/schemas/content-types.json
Element schemas
An Element's schema is defined in public/data/schemas/elements.json
like this:
Field | Type | Description |
---|---|---|
name | String | Camel case identifier |
title | String | A succinct label for the Element |
fields | Object | Schema fields for Element |
See common data types for the data types that can be used for Element fields.
Example
https://github.com/richjava/corporate-basic/blob/main/public/data/schemas/elements.json
Global schema
A Global's schema is defined in public/data/schemas/global.json
like this:
Field | Type | Description |
---|---|---|
fields | Object | Schema fields for Element |
See common data types for the data types that can be used for Global fields.
Example
https://github.com/richjava/corporate-basic/blob/main/public/data/schemas/global.json
Section schema
A section's schema is defined in public/data/schemas/sections.json
like this:
Field | Type | Description |
---|---|---|
name | String | Camel case identifier |
type | String | Type of section (possible values: "body", "head") |
fields | Object | Schema fields for the section |
See Section data types for the data types that can be used for Section fields.
Example
https://github.com/richjava/corporate-basic/blob/main/public/data/schemas/sections.json
Data files
- Module data
- Module Page data
- Page data
- Section data
- Template data
- Collections data
- Layout data
- Global data
- App data
Module data
A Module is represents a business use case, like "Make Contact" but is usually named simply with one word (like "Contact"). Learn more about Modules here.
Module Data Model
The public/data/modules.json
JSON file consists of a modules
array. Each object in the array may have the following fields:
Field | Type | Description |
---|---|---|
name | String | Camel case identifier |
title | String | A succinct label for the Module |
description | String | A description of how the module fulfills a use case |
required | Boolean | Determines if Module is required |
modulePages | Array | References the ModulePages used in the Module. name property in each object in array is reference to module page. |
Example
public/data/modules.json
https://github.com/richjava/corporate-basic/blob/main/public/data/modules.json
Module Page data
A Module Page contains a Page and a collection of Sections.
ModulePage Data Model
The public/data/module-pages.json
JSON file consists of a modulePages
array. Each object in the array may have the following fields:
Field | Type | Description |
---|---|---|
name | String | Camel case identifier |
page | Object | References Page used in the ModulePage. name property is reference to page. |
sections | Array of objects | References Sections used in the ModulePage. Object has name and position properties. name property is reference to section. position property is a value representing the section's approximate initial position in the page when displayed Built Studio. The position property can be between 1 and 20 for body sections and 0 and -20 for head sections. |
Example
https://github.com/richjava/corporate-basic/blob/main/public/data/module-pages.json
Page data
A Page represents a web page.
Page Data Model
The public/data/pages.json
JSON file consists of a pages
array. Each object in the array may have the following fields:
Field | Type | Description |
---|---|---|
name | String | Camel case identifier |
title | String | (Optional) A succinct label for the Page. |
contentType | Object | (Optional) Specified if the page is used as an article. Object has name and config properties. name property is reference to content type. config object can have a populate array. |
Example for a regular page
Example for an article page
https://github.com/richjava/corporate-basic/blob/main/public/data/pages.json
Section data
A Section is a main part of a website page. It contains one or more Templates.
Section Data Model
The public/data/sections.json
JSON file consists of a sections
array. Each object in the array may have the following fields:
Field | Type | Description |
---|---|---|
name | String | Camel case identifier |
title | String | A succinct label for the Section |
type | String | Category of section (possible values: "layout","body", "head"). Default: "body". |
description | String | Description of section |
templates | Array | References templates used by section |
defaultTemplate | Object | Template that will be used by default. name property is reference to template. |
data | Object | Data for the Section as defined in the content type schema |
collections | Object | References collections used by section. Key is the content type name and value is an object with config and article properties. config can have limit , offset and populate properties. populate is an array of reference objects. article is used as a reference to the module page that is used for the article page (which is a Next.js dynamic-route) |
Example
https://github.com/richjava/corporate-basic/blob/main/public/data/sections.json
Template data
A Template represents the user interface of a Section. For example, the UI for a FAQ Section could be designed in a number of ways - an accordian, a list, etc. You can create a template for each of these designs and add them to your Section. Then in the Built Studio the end user of the Theme can decide which Template to use for the Section.
A Template contains a reference to a React component. A Template may contain Elements.
The public/data/templates.json
JSON file consists of a templates
array. Each object in the array may have the following fields:
Template Data Model
Field | Type | Description |
---|---|---|
name | String | Camel case identifier |
title | String | A succinct label for the Template |
category | String | Category of section (examples: "banners", "covers") |
description | String | Description of pageSection |
repoUrl | String | Web address of git repository |
Example
https://github.com/richjava/corporate-basic/blob/main/public/data/templates.json
Collections data
Collection data is kept in json files that have the plural name of the Content Type which defines the data fields, for example "authors.json".
The JSON file consists of a data
array. Along with the data fields for a Content Type, each Entry object in a Collection array must contain the following three fields:
Field | Type | Description |
---|---|---|
_id | String | Camel case identifier |
_type | String | A succinct label for the Collection |
slug | String | Lower case name with dashes |
Example
https://github.com/richjava/corporate-basic/blob/main/public/data/collections/authors.json
Layout data
Layout specifies the header and footer and any otherf layout sections of a site.
Layout Data Model
The public/data/layout.json
JSON file consists of a layout
object with the following fields:
Field | Type | Description |
---|---|---|
contentIndex | Number | The main sections of the page will be placed at this specified index of the sections array. |
sections | Array | The layout sections of a site, for example "header" and "footer". Each object in array has a name property reference to the section. |
Example
https://github.com/richjava/corporate-basic/blob/main/public/data/layout.json
Global data
Global data is available to every page in the site. You can define the Global field names yourself.
The public/data/global.json
JSON file consists of a global
object with the fields defined in the Global schema file:
Example
https://github.com/richjava/corporate-basic/blob/main/public/data/global.json
App data
App data describes the theme or plugin. For a theme, this data is located in public/data/theme.json
. For a plugin, it will be in public/data/plugin.json
.
Shared Data Model for themes and plugins
The public/data/theme.json
or public/data/plugin.json
JSON file consists of a theme
or plugin
object with the following fields:
Field | Type | Description |
---|---|---|
title | String | Name of Theme |
namespace | String | Unique name which uses this name convention: [provider]_[owner]_[repo-name] . For example, gh_richjava_builtjs_corporate . Values for provider can be gh (Github), gl (Gitlab), or bb (Bitbucket). |
description | String | Description of Theme |
imageUrl | String | Image to represent Theme |
demoUrl | String | (Optional) Web address of demo website |
repoUrl | String | (Optional) Git repository web address |
config | Object | (Optional) May specify the Node dependencies and dev dependencies to be installed into the built site |
designSystem | String | (Optional) Name of design system (camel case) |
Theme-specific App Data
A theme also has the following field:
Field | Type | Description |
---|---|---|
plugins | Array | Plugins included in theme (referenced by plugin namespace) |
Example theme.json
https://github.com/richjava/corporate-basic/blob/main/public/data/theme.json
Plugin-specific App Data
A plugin also has the following field:
Field | Type | Description |
---|---|---|
mainModule | Object | The module used for the plugin. name property is reference to module. |
Example plugin.json
https://github.com/richjava/blog-basic/blob/main/public/data/plugin.json
If you haven't done so already, find out more about Built.js concepts.