Where to organize document schemas in Sanity Studio folder structure?
Great question! Organizing your Sanity Studio folder structure can definitely get messy as projects grow. While Sanity doesn't enforce a strict folder structure (since everything is schema-as-code), here are some practical patterns that work well:
Common Folder Structure Patterns
Group by content type categories:
schemas/
├── documents/ # Top-level content types
│ ├── page.ts
│ ├── post.ts
│ └── author.ts
├── objects/ # Reusable nested objects
│ ├── seo.ts
│ ├── hero.ts
│ └── cta.ts
├── blocks/ # Portable Text blocks
│ ├── customImage.ts
│ └── callout.ts
└── singletons/ # One-off documents
├── settings.ts
└── navigation.tsOr group by feature/domain:
schemas/
├── blog/
│ ├── post.ts
│ ├── category.ts
│ └── author.ts
├── commerce/
│ ├── product.ts
│ └── collection.ts
├── pages/
│ ├── page.ts
│ └── landingPage.ts
└── shared/
├── seo.ts
└── media.tsKey Organization Tips
Separate by schema type hierarchy:
- Documents (
type: 'document'): Top-level content that appears in your desk structure - Objects (
type: 'object'): Reusable components that nest inside documents - Singletons: Documents that should only have one instance (site settings, global config)
Consider what editors see: Your folder structure doesn't affect the Studio UI that editors see - that's controlled by your Structure tool configuration. So organize files for developer clarity, not editor experience.
Keep related schemas together: If a schema is only used by one document type, consider keeping them in the same folder or file.
Use an index file: Create an index.ts in your schemas folder that imports and exports all schema types. This gives you one place to manage what's registered in your Studio.
The beauty of Sanity's schema-as-code approach is there's no "wrong" answer - it's just JavaScript/TypeScript files. Pick a structure that makes sense for your team's mental model and refactor as needed. The schemas will work the same regardless of folder organization!
Most teams find the first pattern (documents/objects/blocks/singletons) works well as a starting point, then add domain-specific folders as the project grows. Good luck with the cleanup! 😄
Show original thread18 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.