See how we built our intranet. Live + Q&A, June 30

How to create schema for series episodes with multiple URL fields in Sanity?

49 repliesLast updated: Nov 29, 2025

Hello everyone, I am making a project in which have movies and series, i have achieved movie part which have link/url of the movie but i want to make schema for episode in series, in which i need to have like + button where i can add url fields and add multiple links to one episode. For example, One season have multiple episode and for the multiple episode there are multiple links to each episode of the season. user Y
AI Update

You'll want to use an array field with object members for your episode schema! This is perfect for your use case where each episode needs multiple streaming links.

Here's how to structure your series schema:

import {defineType, defineField, defineArrayMember} from 'sanity'

export default defineType({
  name: 'series',
  title: 'Series',
  type: 'document',
  fields: [
    defineField({
      name: 'title',
      title: 'Series Title',
      type: 'string',
    }),
    defineField({
      name: 'seasons',
      title: 'Seasons',
      type: 'array',
      of: [
        defineArrayMember({
          type: 'object',
          name: 'season',
          title: 'Season',
          fields: [
            {
              name: 'seasonNumber',
              title: 'Season Number',
              type: 'number',
            },
            {
              name: 'episodes',
              title: 'Episodes',
              type: 'array',
              of: [
                defineArrayMember({
                  type: 'object',
                  name: 'episode',
                  title: 'Episode',
                  fields: [
                    {
                      name: 'episodeNumber',
                      title: 'Episode Number',
                      type: 'number',
                    },
                    {
                      name: 'title',
                      title: 'Episode Title',
                      type: 'string',
                    },
                    {
                      name: 'streamingLinks',
                      title: 'Streaming Links',
                      type: 'array',
                      of: [
                        defineArrayMember({
                          type: 'object',
                          name: 'link',
                          fields: [
                            {
                              name: 'url',
                              title: 'URL',
                              type: 'url',
                            },
                            {
                              name: 'platform',
                              title: 'Platform Name',
                              type: 'string',
                              description: 'e.g., Netflix, Prime Video, etc.'
                            },
                            {
                              name: 'quality',
                              title: 'Quality',
                              type: 'string',
                              options: {
                                list: ['720p', '1080p', '4K']
                              }
                            }
                          ],
                          preview: {
                            select: {
                              title: 'platform',
                              subtitle: 'url'
                            }
                          }
                        })
                      ]
                    }
                  ],
                  preview: {
                    select: {
                      title: 'title',
                      episode: 'episodeNumber'
                    },
                    prepare({title, episode}) {
                      return {
                        title: `Episode ${episode}: ${title}`
                      }
                    }
                  }
                })
              ]
            }
          ],
          preview: {
            select: {
              season: 'seasonNumber'
            },
            prepare({season}) {
              return {
                title: `Season ${season}`
              }
            }
          }
        })
      ]
    })
  ]
})

This schema gives you:

In the Studio, users will:

You can also add validation if needed (like requiring at least one streaming link per episode):

{
  name: 'streamingLinks',
  title: 'Streaming Links',
  type: 'array',
  validation: Rule => Rule.required().min(1).error('At least one streaming link is required'),
  of: [...]
}

The array field documentation has more details on customization options if you want to enhance the UI further!

Show original thread
49 replies

Was this answer helpful?

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.

Related contributions