πŸ‘€ Our most exciting product launch yet πŸš€ Join us May 8th for Sanity Connect

Issue with external links not defined in schema in Sanity Studio.

9 replies
Last updated: Jan 18, 2022
Hey everyone, I'm trying to get external links working via the studio, following the guide here https://www.sanity.io/guides/portable-text-internal-and-external-links . When working locally I can see the option to "Open in new window" in the editor, but in the live studio it says:

This field is not defined in the schema, which could mean that the field definition has been removed or that someone else has added it to their own local project and have not deployed their changes yet.

Does anyone know why this is? I've deployed my changes so I'm not sure why it thinks it's not defined in the schema
πŸ€”

blockContent.js
marks: {
        decorators: [
          { title: 'Strong', value: 'strong' },
          { title: 'Emphasis', value: 'em' },
        ],
        
        annotations: [
          {
            name: 'link',
            type: 'object',
            title: 'URL',
            fields: [
              {
                title: 'URL',
                name: 'href',
                type: 'url',
              },
              // External links
              {
                title: 'Open in new window',
                name: 'blank',
                type: 'boolean'
              }
            ],
          },
        ],
      },
Jan 15, 2022, 4:33 PM
Is that the entirety of your file? It doesn't appear to be a default export. If you're calling for it in the main schema.js (or in a desk structure you've customized) it might not be able to import enough for the system to identify it and use it.
Jan 15, 2022, 4:35 PM
This is just what I thought was the relevant snippet. The entire file is:

export default {
  title: 'Block Content',
  name: 'blockContent',
  type: 'array',
  of: [
    {
      title: 'Block',
      type: 'block',
      styles: [
        { title: 'Normal', value: 'normal' },
        { title: 'H1', value: 'h1' },
        { title: 'H2', value: 'h2' },
        { title: 'H3', value: 'h3' },
        { title: 'H4', value: 'h4' },
        { title: 'Quote', value: 'blockquote' },
      ],
      lists: [{ title: 'Bullet', value: 'bullet' }],
      marks: {
        decorators: [
          { title: 'Strong', value: 'strong' },
          { title: 'Emphasis', value: 'em' },
        ],
        annotations: [
          {
            name: 'link',
            type: 'object',
            title: 'URL',
            fields: [
              {
                title: 'URL',
                name: 'href',
                type: 'url',
              },
              // External links
              {
                title: 'Open in new window',
                name: 'blank',
                type: 'boolean'
              }
            ],
          },
        ],
      },
    },
    {
      type: 'image',
      options: { hotspot: true },
    },
  ],
}
Jan 15, 2022, 4:41 PM
Ah, okay. Just checking. I went to text-compare.com and put yours on the left and mine on the right because I am literally using the same example live and it's working for me. Aside from validation, which shouldn't be relevant, we're doing the same thing. Pretty weird!
Jan 15, 2022, 5:14 PM
Hm, that is strange! What happens if you run
sanity undeploy
then
sanity deploy
once more?
Jan 17, 2022, 10:26 PM
should I run this locally?
Jan 18, 2022, 5:42 PM
Correct!
Jan 18, 2022, 5:45 PM
ahh you star!
Jan 18, 2022, 5:51 PM
that's fixed it, thanks both of you for your help!
Jan 18, 2022, 5:52 PM
Fantastic! I love when a redeploy magically fixes things πŸ˜…
Jan 18, 2022, 5:58 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?