Go Behind the Experience to see how Tecovas brings the West to life with Sanity 🤠 July 18th

Issue with parent/child taxonomy template in Sanity Studio v3

6 replies
Last updated: Jun 2, 2024
Hi all!I’ve been following User’s “Creating a Parent/Child Taxonomy” guide, up until the Pre-flight check section. I’ve copied the files exactly, yet when I try to access the documents I’ve created from the initial “All” folder, I get this error message:

Structure path


template id (`templateId`) is required for initial value template item nodes

I can access the documents if I go via one of the sub folders, which implies that the issue should be located at the bottom of the parentChild.ts file, here:

child: () =>


_type == $schemaType && parent._ref == $parentId
.params({ schemaType, parentId: parent._id })

// Use this list for creating from child menu

.canHandleIntent((intentName, params) => intentName === 'create' && params.template === 'category-child')


S.initialValueTemplateItem('category-child', {

parentId: parent._id,



I can't seem to find the error, everything looks fine to me. Has anyone else experienced this same issue? All help is greatly appreciated
May 31, 2024, 3:18 PM
For fun, I tried replacing initialValueTemplates with
.child(S.documentWithInitialValueTemplate('category-child', { parentId: parent._id })),
, which produces a slightly different error msg:
Error: Template with ID "category-child" not defined

Could it be that the structure builder is run before the templates function inside sanity.config.ts? Seems weird, tho...
May 31, 2024, 3:25 PM
👋 What version of the Studio are you running?
May 31, 2024, 5:23 PM
Oh wait, actually, have you defined the template, like so:
// ./sanity.config.ts

import {defineConfig} from 'sanity'
import {schemaTypes} from './schemas'

export default defineConfig({
  // ...all other settings
  schema: {
    // All your schema types
    types: schemaTypes,
    // Add this 'category child' template
    templates: (prev) => {
      const categoryChild = {
        id: 'category-child',
        title: 'Category: Child',
        schemaType: 'category',
        parameters: [{name: `parentId`, title: `Parent ID`, type: `string`}],
        // This value will be passed-in from desk structure
        value: ({parentId}: {parentId: string}) => ({
          parent: {_type: 'reference', _ref: parentId},
      return [...prev, categoryChild]
May 31, 2024, 5:25 PM
That's a good guess as to why it wouldn't have worked, but I have indeed added the template.
May 31, 2024, 8:16 PM
And it's v3 of the studio, the project was started no more than a month ago.
May 31, 2024, 8:18 PM
I just realized what I did, a silly little mistake. I placed the templates outside of the schema object in sanity.config.ts 😛
Jun 2, 2024, 8:27 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?