Discussion on enabling deskStructure titles in other languages

23 replies
Last updated: Jun 20, 2022
Is there a way to enable setting deskStructure title's in other languages? I get an error any time that I try adding titles in Cyrillic
AI Update

The issue you're encountering is a common one - Sanity's Structure Builder requires that list item IDs must contain only alphanumeric characters (letters A-Z, a-z, numbers 0-9, and sometimes hyphens/underscores). This means Cyrillic characters, emojis, and other Unicode characters aren't allowed in the id field.

However, there's good news: you can absolutely use Cyrillic (or any other language) in the title field. The id and title are separate properties:

  • id: Must be alphanumeric (used internally for routing and identification)
  • title: Can contain any characters including Cyrillic, Chinese, Arabic, emojis, etc. (this is what users see)

Here's how to properly structure your desk configuration:

S.listItem()
  .id('events') // Must be alphanumeric
  .title('События') // Can be Cyrillic!
  .child(
    S.documentTypeList('event')
      .title('Все события')
  )

Or with documentTypeListItem:

S.documentTypeListItem('artist')
  .id('artists') // Alphanumeric ID
  .title('Артисты') // Cyrillic title - totally fine!

The key is to always provide an explicit id() with alphanumeric characters, and then use title() for your localized display text. The Structure Builder uses the ID for internal navigation and routing (it appears in the URL), while the title is what appears in the Studio UI.

If you're getting errors, it's likely because either:

  1. You're trying to use Cyrillic characters in the .id() method
  2. You're only setting a title without an explicit ID, and Sanity is trying to auto-generate an ID from your Cyrillic title

Always set both explicitly, and you'll be able to use any language you want for your visible titles while keeping the technical IDs in alphanumeric format.

Can you show me the code snippet that triggers this please? Just the way you declare the field. 🙂
thanks for the quick reply
Ah right, you said the desk structure, not the schema. My bad. Alright, and it fails on the “Settings” translation, right?
I found it quite strange, as this sort of format works fine for titles inside of documents
any time I try to define a title in the deskStructure file that comes with the basic studio templates, it gives me that error, yeah. sorry
whereas with actual documents, it allows me to set the title however I want.
Right. Looking at the code , it seems that identifiers need to stick to a specific latin subset. That would go for ids, refs, types, etc. I think.
as with actual document, or object titles, I thought they were purely presentational? the .title() is in no way an identifier, is it?
That is my understanding of it, yes.
perhaps the deskStructure uses the title field as some sort of unique identifier, which is why only in that instance, it requires latin?
As far as I can tell, this error should only happen when you pass non-latin characters to
.documentId()
,
.id()
or
.schemaType()
. But it should be fine for
.title()
. Can you confirm?
I can confirm. This error shouldn't be happening. It doesn't make sense
Ah wait.
this is a .title() for a S.listItem() in the deskStructure; purely presentational
Can you please define the
.title()
after the other calls?
Looking at the code again, it seems that it uses
.spec.id
if defined, otherwise camelCase the title. But at this stage, the spec ID is not defined because you call the title method first.
like this? Is it possible to perhaps add a different field that would get used for that?
because the above image doesn't work. it still gives me the error
Right, so as far as I understand the code, it seems that calling the
.title()
method does not only set the title for some reason, it also set the ID. It first tries to read it on the list item instance (
.spec.id
) and if it’s not there (which is your case here) it derives the ID from the title — which is likely where the error comes from. So I’m wondering if we can try to define the title after we have defined the ID (one way or another). Still digging through the code.
adding a .id() property works
Right, that was what I was about to suggest as well. Define the ID yourself, and then define the title. This will make sure the call doesn’t derive an ID from the title.
this is what worked out. thank you very much. I appreciate the quick response and patience
That was a nifty one. Pretty weird if you ask me. I’m glad we figured it out though! 💚

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?