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

49 replies
Last 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:

  1. Nested arrays - Series → Seasons → Episodes → Streaming Links
  2. The + button you want - Array fields automatically provide the "Add item" button for adding multiple URLs
  3. Custom previews - So you can see episode titles and platform names at a glance without opening each item
  4. Flexible link structure - Each episode can have as many streaming links as needed

In the Studio, users will:

  1. Click the + button next to "Streaming Links"
  2. Add a URL, platform name, and quality for each link
  3. Keep clicking + to add more links to that episode

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

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?