References showing as "untitled" in Sanity array - how to add preview?

34 replies
Last updated: Jan 28, 2026
Hello everyone,I was wondering if someone could help me with my problem?
Currently in a schema I defined fields of a custom type "section"(type :'object'). this schema contains an array of references. When I now try to add references, they are shown as untitled. how can i change that?

export default {
    title: 'Versprechen Page',
    name: 'promise',
    type: 'document',
    ...
    fields: [
        {
            name: 'section1',
            type: 'section',
            fieldset: 'sectionGroup0'
        },
        ... ]
}

export default {
    title: 'Abschnitt',
    name: 'section',
    type: 'document',
    fields: [
        ...
        {
            title: 'Content',
            name: 'content',
            type: 'array',
            of: [
                {
                    type: 'reference',
                    to: [
                        {type: 'pictureAndText'},
                        {type: 'titleAndText'},
                        {type: 'collection'},
                        {type: 'link'}
                    ]
                }
            ]
        },
       ...
    ],
}

AI Update

The issue you're seeing is that the referenced documents don't have a preview configuration set up, so Sanity defaults to showing "Untitled". You need to add a preview configuration to each of the referenced document types (pictureAndText, titleAndText, collection, and link).

Here's how to fix it by adding preview configuration to your referenced schemas:

// pictureAndText.js (example)
export default {
    title: 'Picture and Text',
    name: 'pictureAndText',
    type: 'document',
    fields: [
        {
            name: 'title',
            type: 'string'
        },
        {
            name: 'picture',
            type: 'image'
        },
        // ... other fields
    ],
    preview: {
        select: {
            title: 'title',
            media: 'picture'
        }
    }
}

The preview object has two parts:

  • select: Specifies which fields to use in the preview
  • prepare (optional): Transforms the data before display

For a basic setup, just using select with a title field is usually enough. If your documents don't have a field literally named "title", adjust it to whatever field makes sense:

preview: {
    select: {
        title: 'name',  // or whatever your main identifying field is
        media: 'image'   // optional: shows a thumbnail
    }
}

If you need more control over how the preview displays, you can add a prepare function:

preview: {
    select: {
        title: 'title',
        subtitle: 'description',
        media: 'image'
    },
    prepare({title, subtitle, media}) {
        return {
            title: title || 'Untitled',
            subtitle: subtitle,
            media: media
        }
    }
}

Apply this pattern to all four of your referenced document types (pictureAndText, titleAndText, collection, and link), and the references in your array will show meaningful titles instead of "Untitled".

Note: One small issue in your code - you've defined section as type: 'document', but since you're using it as a field type within another document, it should probably be type: 'object' instead. Documents are top-level content types, while objects are embedded within documents.

Show original thread
34 replies

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?