👋 Next.js Conf 2024: Come build, party, run, and connect with us! See all events

Removing the "Create New Document" icon and omitting certain documents in Sanity.

7 replies
Last updated: Jul 15, 2022
Hey everyone! I have used Sanity for a while, but I just noticed (after all these years) that the
Create New Document
icon on the top bar allows a user to create documents that I may not want created. For instance I have document types such as the
homePage
and
siteSettings
that I do not want to be created again... This hasnt been an issue for me or my clients, because I always tell them to create documents within the editor. I am wondering if its possible to remove the
Create New Document
icon or perhaps omit certain documents from that?
Jul 14, 2022, 8:56 PM
Hi User. Yes, you can do this. One way is using actions , which are easier to implement but are experimental and will be deprecated soon (per those docs—I don’t know details on this). The second way is using initial value templates , which take a bit more to set up but this is the “preferred” method going forward.
Jul 14, 2022, 9:00 PM
Thanks for this
user A
... I may go with the actions since I can see how that works a bit better. I am a bit confused on how to implement omitting certain documents with the example provided within the initial value templates.
Though maybe I'll just figure that out as a future-proof solution
Jul 14, 2022, 9:20 PM
Sounds good. Sometimes a deprecation needs to be tomorrow’s problem. 😆
Jul 14, 2022, 9:21 PM
Lol maybe it will be deprecated in like 5-10 years? Just don't tell anyone about this issue ya know? 😝
Jul 14, 2022, 9:23 PM
Actually
user A
I see there is an example of this on the Hydrogen Studio template...
user F
has a
constants.js
set up that feeds into
newDocumentStructure.js


https://github.com/sanity-io/sanity-shopify-studio/blob/c03de5e8d951ac737d5b0cd4a8a0b3e76b125a13/parts/newDocumentStructure.js
So I may just copy this!
Jul 14, 2022, 9:29 PM
Nice! Solving problems ahead of schedule.
Jul 14, 2022, 9: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?