Concepts

Content type data

Content type data concepts for Built.js themes and plugins.

A content type defines the fields for an entry of a collection (see "Collections and entries").

This is an example of an "author" content type and the author's profile:

public/data/schemas/content-types.json
{
  "contentTypes": [
    {
      "name": "author",
      "title": "Author",
      "dataPosition": 2,
      "fields": {
        "fullName": {
          "type": "string"
        },
        "slug": {
          "type": "uid",
          "targetField": "fullName",
          "required": true
        },
        "profile": {
          "type": "relation",
          "relation": "oneToOne",
          "target": "profile"
        }
      }
    },
    {
      "name": "profile",
      "title": "Profile",
      "dataPosition": 1,
      "fields": {
        "title": {
          "type": "string",
          "required": false
        },
        "excerpt": {
          "type": "text",
          "required": false
        },
        "bio": {
          "type": "portabletext"
        },
        "position": {
          "type": "string",
          "required": false
        },
        "profileImage": {
          "type": "image"
        }
      }
    }
  ]
}

The dataPosition property 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.

The fields available for a content type are:

biginteger

PropertyDescriptionRequired
typeThe data typetrue
requiredDetermines if value is required. Default: falsefalse

boolean

PropertyDescriptionRequired
typeThe data typetrue
requiredDetermines if value is required. Default: falsefalse

date

PropertyDescriptionRequired
typeThe data typetrue
requiredDetermines if value is required. Default: falsefalse

decimal

PropertyDescriptionRequired
typeThe data typetrue
requiredDetermines if value is required. Default: falsefalse

element

An Element represents a reusable UI component.

PropertyDescriptionRequired
typeThe data typetrue
elementName of the elementtrue
repeatableWhether the value is single or multiple values. Default: falsefalse
requiredDetermines if value is required. Default: falsefalse

email

PropertyDescriptionRequired
typeThe data typetrue
requiredDetermines if value is required. Default: falsefalse

enumeration

PropertyDescriptionRequired
typeThe data typetrue
valuesComma separated list of string values.true
requiredDetermines if value is required. Default: falsefalse

integer

PropertyDescriptionRequired
typeThe data typetrue
requiredDetermines if value is required. Default: falsefalse

json

PropertyDescriptionRequired
typeThe data typetrue
requiredDetermines if value is required. Default: falsefalse

password

PropertyDescriptionRequired
typeThe data typetrue
requiredDetermines if value is required. Default: falsefalse

portabletext

Portable Text is a presentation-agnostic specification for block content that you can use with Sanity.

PropertyDescriptionRequired
typeThe data typetrue
requiredDetermines if value is required. Default: falsefalse

relation

A relation describes a relationship between this content type and another.

PropertyDescriptionRequired
typeThe data typetrue
targetThe name of the relation content type.true
relationonToOne, manyToOne or oneToManytrue
requiredDetermines if value is required. Default: falsefalse

string

PropertyDescriptionRequired
typeThe data typetrue
requiredDetermines if value is required. Default: falsefalse

text

PropertyDescriptionRequired
typeThe data typetrue
requiredDetermines if value is required. Default: falsefalse

time

PropertyDescriptionRequired
typeThe data typetrue
requiredDetermines if value is required. Default: falsefalse

uid

A data type for slugs which is typically used to create unique URLs.

PropertyDescriptionRequired
typeThe data typetrue
targetFieldThe name of the field to create the slug from.true
requiredDetermines if value is required.true

On this page