Unlock seamless workflows and faster delivery with our latest releases - Join the deep dive

Structuring documents and categories in Sanity.io

5 replies
Last updated: Sep 11, 2022
So I struggle with structuring my documents. I have tags that are categorised. I want to be able to create a category and within that category I want to create tags in sanity.
this is how far I got. I tried to use filter in deskStructure. But then I wasn't able to create more categories.

I am not sure what should be my approach here. Any ideas or tips?
😅
Sep 6, 2022, 2:18 PM
Hello
user E
The problem you’re seeing, is because you try to define the structure within a document.
*These are separate in Sanity*: one is the
schemas
, where you define your
documents
and
objects
, one is your structure in the
desk
, which is done with the Structure-Builder API
These 2 guides could help you setup a
desk structure
you want to get working:
https://www.sanity.io/docs/structure-builder-introduction
https://www.sanity.io/guides/getting-started-with-structure-builder In addition: *think of nesting documents as referencing each other*: so setting up
references should be your way to go in your schemas!
I am unsure, which relations your categories, tags and other docs will have, but maybe set those up first with the help of the explanations from above.
After setting up your custom desk structure, you can then use
initialValueTemplates in the desk structure to pre-define, which references the newly created tags/categories will have.
But first: get accustomed to
references
(and
arrays
of references) and decide which logic they will follow and then take the next step of setting up a custom
desk structure
. Then adding
initalValueTemplates
and voila 😉
Sep 8, 2022, 1:42 PM
Thanks! We actually dropped that structure that I showed here and went for references. This is very helpful. I will look it this further :smiling-sun:
Sep 8, 2022, 1:49 PM
If you drop stuff, can you please mark your questions as resolved by adding to the message, I am alone atm and have spent quite a lot of time with your stuff which you no longer need.
Sep 8, 2022, 8:02 PM
Sorry I will do that next time. 🙏
Sep 9, 2022, 6:38 AM
Don't worry we all forget things especially when we are stressed because things don't work. 😊 So we remind people.
Sep 11, 2022, 8:30 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?