Image schemas not appearing in Sanity Studio structure despite no errors

2 replies
Last updated: Jan 21, 2024
Hello everyone 🙂So super new at this and im at a loss, as I dont get an error but I cant se the image schemas in sanity

// schemas/index.js

console.log('Importing schemas...');

import text1 from './text1';

import text2 from './text2';

import text3 from './text3';

import text4 from './text4';

import image1 from './image1';

import image2 from './image2';

import image3 from './image3';

console.log('Schemas imported:', [text1, text2, text3, text4, image1, image2, image3]);

const schemaTypes = [text1, text2, text3, text4, image1, image2, image3];

console.log('Exporting schemaTypes:', schemaTypes);

export default schemaTypes;

import {defineConfig} from 'sanity'
import { structureTool } from 'sanity/structure'
import schemaTypes  from './schemas/index'

console.log('Configuring Sanity Studio...');

console.log('Imported schemaTypes:', schemaTypes);

export default defineConfig({
  title: "",
  projectId: "xxxxxxx",
  dataset: "xxxxxx",
  plugins: [structureTool()],

  schema: {
    types: schemaTypes,
  },
});
console.log('Sanity Studio configuration:', defineConfig);
// schemas/image.js
export default {
    name: 'image1',
    title: 'Image1',
    type: 'image',
    options: {
      hotspot: true,
    },
    fields: [
        {
          name: 'caption',
          type: 'string',
          title: 'Caption',
        },
        {
          name: 'attribution',
          type: 'string',
          title: 'Attribution',
        }
      ]
    }
  
I cant understand why I cant see it in the structure...
AI Update

I can see your issue! Your image schemas are configured correctly, but they won't show up in the Structure Tool's default navigation because image types are not document types - they're object types meant to be used as fields within documents.

The Structure Tool only displays document types in its main navigation. Since you defined your image schemas with type: 'image', they're treated as reusable image field definitions, not standalone documents.

Your current setup:

export default {
  name: 'image1',
  type: 'image',  // This makes it an object/field type, not a document
  // ...
}

To make them appear in Studio, you have two options:

Option 1: Change them to document types (if you want standalone image documents):

export default {
  name: 'image1',
  title: 'Image1',
  type: 'document',  // Changed from 'image' to 'document'
  fields: [
    {
      name: 'image',
      type: 'image',
      title: 'Image',
      options: {
        hotspot: true,
      },
    },
    {
      name: 'caption',
      type: 'string',
      title: 'Caption',
    },
    {
      name: 'attribution',
      type: 'string',
      title: 'Attribution',
    }
  ]
}

Option 2: Use them as fields in your text documents (more common pattern):

// In your text1.js, text2.js, etc.
export default {
  name: 'text1',
  type: 'document',
  fields: [
    {
      name: 'content',
      type: 'string',
      // ... other fields
    },
    {
      name: 'featuredImage',
      type: 'image1',  // Reference your custom image type
      title: 'Featured Image'
    }
  ]
}

Most likely, you want Option 1 - to make them actual document types that can be created and managed independently in Studio. Just change type: 'image' to type: 'document' and nest the actual image field inside.

The key concept: In Sanity, only schemas with type: 'document' appear in the Studio navigation. Everything else (type: 'image', type: 'object', etc.) are building blocks used within documents. You can learn more about this in the schema types documentation.

Show original thread
2 replies
Only documents can be viewed in your structure. You’ll need to put your image inside of a document.
Oh ok! Thanks 🙂

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?