🔮 Sanity Create is here. Writing is reinvented. Try now, no developer setup

Advice on organizing folder structures and schemas in Sanity.io projects

18 replies
Last updated: Feb 5, 2022
Need some advice here. I have this folder structure of the studio where basically almost everything is inside the “documents” folder. I want to cleanup the folder and make it more readable and logical.
Any tips ? Where would you move the docs in which folder because it can be pretty tough somethimes
😄
Feb 4, 2022, 10:46 AM
Hey Nino. One approach you could take is to group your files by "concern". That is, to have multiple directories for each "concern" (e.g. "settings" or "articles") and to have
documents
and
objects
etc. directories inside each of those.
You could even use plugins to help do this grouping (
https://www.sanity.io/docs/plugins ), however it's not strictly necessary because you can load your schemas from any location.
Feb 4, 2022, 3:28 PM
user E
Which plugin do I need don’t see it on this page. Love Sanity, only issue is something structure on how to make it readable and clean.
Feb 4, 2022, 3:31 PM
Is it the “sanity install third-party-reviews” plugin
Feb 4, 2022, 3:32 PM
Sorry, I didn't explain that very well. What I meant is that you can create a plugin for each of your "concerns" (different parts of your app) and keep them in the
plugins
directory only for you. Your plugins don't have to add anything to the Studio UI, you can simply use them as a clean way to organise your code 🙂.
This page might be helpful:
https://www.sanity.io/guides/creating-my-first-sanity-io-plugin .
Feb 4, 2022, 3:34 PM
Thank you. I see a lot of people having modules, objects and documents. From multiple demo starters from Sanity. maybe I should do the same. But keeping code organized is never easy.
Feb 4, 2022, 3:36 PM
My current play project is nowhere near as complex as yours, but one of the first things I do to stay “sane” is organize my schema files into a simple file system that makes sense to me for the project I am doing. In this case, a simple blog concept. The naming conventions for directories within
./schemas
don’t matter as much as the imports and datatypes. In my case, I wanted to set up two different portable text block content inputs, so I created two objects named
ptext
and
ptextLite
, and this works how I want.
Feb 4, 2022, 5:27 PM
user U
Thanks for sharing! I will first follow the design and based on the elements build documents and modules.
Feb 4, 2022, 8:06 PM
I often browse public repos from the Sanity team and community submissions for inspiration. Sounds like you’re on a good path!
Feb 4, 2022, 8:08 PM
user U
Yes, I’v setup some of the Sanity team and community demos to take inspiration from. Usually I see modules, documents, objects.
Feb 4, 2022, 8:10 PM
My current little blog workflow experiment that I’m using to test community questions as well is intended to be a platform for a handful of my own different sites. As I add different documents for different projects, I may switch my file layout to match the different sub projects. I don’t have a prescriptive suggestion for you, but part of the fun in all of this is coming up with my own methods!
Feb 4, 2022, 8:13 PM
My current little blog workflow experiment that I’m using to test community questions as well is intended to be a platform for a handful of my own different sites. As I add different documents for different projects, I may switch my file layout to match the different sub projects. I don’t have a prescriptive suggestion for you, but part of the fun in all of this is coming up with my own methods!
Feb 4, 2022, 8:13 PM
user U
Agree here if you think about it, there is no good or bad as long as it makes sense on the long term if you have to update it. Naming is the most important page, category, tag, list etc etc.
Feb 4, 2022, 8:17 PM
There are some amazingly deep discussions about best methods and a lot of strong opinions in nearly every dev community. I think I try to organize in a way that seems easiest for someone else to read and easiest for my own workflow. I sometimes start with multiple components combined in a single file, just to break them out - and sometimes with a bunch of different small component documents only to merge them later.
Feb 4, 2022, 8:22 PM
user U
good point, for instance image field/type not to copy paste the same code over and over again, but create one component named image.js and share it with other document files. That’s what you are talking about right?
Feb 4, 2022, 8:24 PM
user U
good point, for instance image field/type not to copy paste the same code over and over again, but create one component named image.js and share it with other document files. That’s what you are talking about right?
Feb 4, 2022, 8:24 PM
user U
May I ask which font are you using I really like it. Could you share the settings from vscode?
Feb 5, 2022, 7:02 PM
Cascadia code and one of the oceanic themes with italics. https://github.com/microsoft/cascadia-code
Feb 5, 2022, 8:38 PM
user U
Thank you very much!
Feb 5, 2022, 11:27 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?