How to view schemas for single pages created in Sanity

7 replies
Last updated: Feb 8, 2021
I created a schema for about page and it's showing in cms but I can't access it...
AI Update

I can help you troubleshoot this! When you create a schema in Sanity but can't access the document in the Studio, there are a few common causes:

1. Schema not added to the config

The most common issue is that your schema needs to be imported and added to your sanity.config.js (or .ts) file. Make sure you've done this:

import { defineConfig } from 'sanity'
import { structureTool } from 'sanity/structure'
import { aboutPage } from './schemas/aboutPage' // your schema file

export default defineConfig({
  // ... other config
  plugins: [
    structureTool()
  ],
  schema: {
    types: [aboutPage], // add your schema here
  },
})

2. Singleton document setup

If your "about page" should only have one instance (which is typical for pages like About), you might need to set it up as a singleton. Without proper configuration, singletons can be created but not easily accessed. Here's how to configure it using the Structure Builder:

// In your schema file
export default {
  name: 'aboutPage',
  type: 'document',
  title: 'About Page',
  fields: [
    // your fields
  ]
}

// In sanity.config.js with Structure Builder
import { structureTool } from 'sanity/structure'

export default defineConfig({
  plugins: [
    structureTool({
      structure: (S) =>
        S.list()
          .title('Content')
          .items([
            S.listItem()
              .title('About Page')
              .child(
                S.document()
                  .schemaType('aboutPage')
                  .documentId('aboutPage')
              ),
            // ... other items
          ])
    })
  ]
})

3. Check if the document exists

The document might be created but hidden in the default view. Try accessing it directly via URL: https://your-studio-url.sanity.studio/structure/aboutPage

4. Restart your dev server

Sometimes the Studio needs a restart after schema changes. Stop your development server and run npm run dev (or yarn dev) again.

The Structure Tool documentation has more details on customizing document visibility and organization if you need more advanced configuration.

yes. dont know why I didnt find it before.
thank you
Of course - thats what we are all here for πŸ™‚
yes. dont know why I didnt find it before.
thank you
Of course - thats what we are all here for πŸ™‚

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?