How to define schema for site settings in Sanity Studio
6 replies
Last updated: May 17, 2020
D
Hi everyone.I'm following the guide
https://www.sanity.io/guides/getting-started-with-structure-builder I've added Site settings and restarted/recompiled the studio.
However, when I click on the 'Site Settings' I get the following error:
Unknown schema type
This document has the schema type
Where do I define the schema for the deskStructure?
https://www.sanity.io/guides/getting-started-with-structure-builder I've added Site settings and restarted/recompiled the studio.
import S from '@sanity/desk-tool/structure-builder'; export default () => S.list() .title(`Content`) .items([ S.listItem() .title(`Site settings`) .child( S.editor() .schemaType(`siteSettings`) .documentId(`siteSettings`) ), // Add visual divider S.divider(), ...S.documentTypeListItems() .filter( listItem => ![`siteSettings`].includes(listItem.getId() )) ])
Unknown schema type
This document has the schema type
siteSettings, which is not defined as a type in the local content studio schema.
Where do I define the schema for the deskStructure?
May 16, 2020, 9:16 PM
P
Hi Jan, have you defined the schema itself for
Full examples here:
•
https://github.com/sanity-io/sanity-template-gatsby-blog/blob/master/template/studio/schemas/documents/siteSettings.js •
https://github.com/sanity-io/sanity-template-gatsby-blog/blob/master/template/studio/schemas/schema.js
siteSettings? Depending on your folder structure, you might have a
siteSettings.jsfile in your
/schemas/documents/folder with the the appropriate contents. Once this file is in place, you will have to add it to your
schema.jsfile:
... import siteSettings from './documents/siteSettings' ... export default createSchema({ types: schemaTypes.concat([ ... siteSettings, ... ]) })
•
https://github.com/sanity-io/sanity-template-gatsby-blog/blob/master/template/studio/schemas/documents/siteSettings.js •
https://github.com/sanity-io/sanity-template-gatsby-blog/blob/master/template/studio/schemas/schema.js
May 16, 2020, 9:23 PM
P
Hi Jan, have you defined the schema itself for
Full examples here:
•
https://github.com/sanity-io/sanity-template-gatsby-blog/blob/master/template/studio/schemas/documents/siteSettings.js •
https://github.com/sanity-io/sanity-template-gatsby-blog/blob/master/template/studio/schemas/schema.js
siteSettings? Depending on your folder structure, you might have a
siteSettings.jsfile in your
/schemas/documents/folder with the the appropriate contents. Once this file is in place, you will have to add it to your
schema.jsfile:
... import siteSettings from './documents/siteSettings' ... export default createSchema({ types: schemaTypes.concat([ ... siteSettings, ... ]) })
•
https://github.com/sanity-io/sanity-template-gatsby-blog/blob/master/template/studio/schemas/documents/siteSettings.js •
https://github.com/sanity-io/sanity-template-gatsby-blog/blob/master/template/studio/schemas/schema.js
May 16, 2020, 9:23 PM
C
Hey, thanks for giving me hints. No, I didn't make the schema, but I wasn't quite sure, how to go about it. I shall read through the links you sent me. Cheers.
May 16, 2020, 9:25 PM
C
Yep, that did the trick! I sort of knew, I needed to define the schema, but I didn't work out how, where to add it, etc. Now it makes so much more sense and it seems obvious. One could even say… sane! (pun intended). Thank you.
May 16, 2020, 9:39 PM
P
Glad no sanity was lost in the process 😄 If you’re interested, there’s some more information on schemas in this guide for example: https://www.sanity.io/docs/content-modelling
May 16, 2020, 10:47 PM
C
Thanks, yes this mini series of short vids is really good. That's what actually got me started in the first place.
May 17, 2020, 9:05 AM
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.