Schemas folder renamed to schemaTypes in new Sanity app?

2 replies
Last updated: Feb 26, 2024
Hey everyone:)
Haven’t used Sanity in a few months. Still new to webdev and I’m worried not to mess something up. There used to be a
schemas
folder, now there’s
schemaTypes
, is it the same thing? Because I can’t find the old one when I created a new app.
The index in
schemaTypes
is still just
export const schemaTypes = []
, but I wanted to make sure I’m doing everything right. The change isn’t reflected on the sanity getting started guide in the docs.

https://www.sanity.io/docs/create-a-schema-and-configure-sanity-studio#03c8fbda856atext=the%20command%20l[…]2%94%9C%E2%94%80%E2%94%80%20README.md
Thank you!
AI Update

Good news – you're doing everything right! Yes, schemaTypes is the same thing as the old schemas folder. This is just a naming convention update in the Sanity Studio starter templates, not a breaking change.

When you create a new Sanity project now, the CLI generates a schemaTypes folder instead of schemas, but functionally they work exactly the same way. The folder name change was made to be more explicit about what the folder contains, but it's just a convention – you could technically name it anything you want.

Your schemaTypes/index.ts (or .js) file starting with export const schemaTypes = [] is perfectly normal for a fresh project. This is where you'll add your schema definitions as you build out your content model. For example:

import myDocumentType from './myDocumentType'

export const schemaTypes = [myDocumentType]

Then in your sanity.config.ts file, you import and use this array:

import {defineConfig} from 'sanity'
import {schemaTypes} from './schemaTypes'

export default defineConfig({
  // ... other config
  schema: {
    types: schemaTypes,
  },
})

You're right that the getting started guide still shows the old schemas folder name in some places – this is just documentation that hasn't been fully updated to reflect the newer starter template convention. The underlying functionality is identical, so you can follow the guide and just mentally swap "schemas" with "schemaTypes."

Don't worry about messing anything up – the folder name is just organizational preference. What matters is that you export your schema types array and import it into your config file correctly, which you're already doing!

Show original thread
2 replies
You’re doing it correctly! Did this show up in a Studio from the CLI or did you clone a template? The naming and structure of the directories ultimately does not matter. As long as the path to whatever you’re trying import is correct, you can structure everything however you want.
Ah good to hear, thank you very much for the feedback! This was from creating a new sanity app from CLI, no template. It just showed up with only
schemaTypes
.

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?