Sanity Studio - an Array of references

Learn how to create an array of references in sanity schema

Array of Reference in Schema

A schema is a document in Sanity studio where content is modeled, such as a blog post, or product in a product list.

Some times we need to provide a set of value from other documents. For example we need to provide multiple categories for blog post.

Reference is a link to a type / document.

Array of reference

In our case we need an array of type category which is a document type. So we have to create a field of categories in post schema as follows

{
  name:'categoryies',

type:'array',

title:'Categories',

of:[
  {

type:'reference',

to:{type:'category'}

 }

],

Restart your sanity studio and try to add multiple categories.

JSON
schema

Write your comment