Watch a live product demo πŸ‘€ See how Sanity powers richer commerce experiences

Project Structure

The file structure of a typical Sanity Studio project

The common way of customizing a CMS is to just replace parts of the code with your own. As most people who have modified a WordPress installation can attest, this makes upgrades difficult and quickly leads to tangled code.

Sanity Studio’s file structure is a slim single-page React application where logic and code are contained in npm modules. The Studio comes with a framework that lets you customize and add your own components to different parts of it.

This makes it possible to confidently upgrade to new versions of Sanity Studio, and also to install and ship plugins in self-contained packages.

Studio File Layout

The file structure of Studio projects can look different depending on how you installed it. The example below is from the blog template example that you can initiate from the CLI:

.
β”œβ”€β”€ README.md
β”œβ”€β”€ dist
β”‚Β Β  β”œβ”€β”€ index.html
β”‚Β Β  └── static
β”‚Β Β      ...
β”‚Β Β      └── ...
β”œβ”€β”€ package-lock.json
β”œβ”€β”€ package.json
β”œβ”€β”€ sanity.cli.ts
β”œβ”€β”€ sanity.config.ts
β”œβ”€β”€ schemas
β”‚Β Β  β”œβ”€β”€ author.ts
β”‚Β Β  β”œβ”€β”€ blockContent.ts
β”‚Β Β  β”œβ”€β”€ category.ts
β”‚Β Β  β”œβ”€β”€ index.ts
β”‚Β Β  └── post.ts
β”œβ”€β”€ static
└── tsconfig.json

Sanity Studio contains the following files and folders out of the box:

  • package.json: Contains the necessary dependencies for the studio project. There will also be a dependency lock file that might look different depending on which package manager you use.
  • sanity.cli.ts: The configuration file for the Sanity CLI. Contains information on what project ID and dataset the CLI should connect to for project-specific commands.
  • sanity.config.ts: The configuration file for the Studio contains information about what project(s) that the Studio should connect to, as well as schemas, plugins, and other customizations.
  • schemas: It's a convention to organize schema files in a dedicated folder. It's not required to have a schemas folder, as schemas are imported as JavaScript into the Studio config object.
  • static: If you want to bundle static files in the studio, you can place these files in the static folder. The built-in developer tooling using Vite will pick these up automatically. If you use a different bundler, then you might need to configure this to bundle files from this folder as well.
  • tsconfig.json (only if TypeScript is used) Contains the settings for the transpilation of TypeScript into JavaScript.
  • dist: This folder is auto-generated and contains the production build of Sanity Studio as a result of running npm run build.

Was this article helpful?