Can dynamic fields be supported in Sanity for Gatsby sites?

6 replies
Last updated: May 11, 2020
I asked a question above and I am worried it was a bit long and scared everyone away. A tldr; version might be "does sanity support dynamic/computed fields?" or "Can I make a field that has its value set/updated from another field or fields?"
May 11, 2020, 8:55 PM
not in sanity but it can be handled elsewhere. gatsby?
May 11, 2020, 9:02 PM
yes i am building a gatsby site. I was hoping i would be able to generate paths for nested documents in sanity.
May 11, 2020, 9:04 PM
Working on a code example in a reply to the original question...
May 11, 2020, 9:07 PM
oh thank you
user K
May 11, 2020, 9:07 PM
nested documents sounds strange but in general you'd handle this in gatsby-node.js when you generate the rolex page
May 11, 2020, 9:08 PM
ill also share an example from one of my projects ๐Ÿ™‚
in gatsby-node.js
a tag is given a slug based on its category

  tags.forEach(tag => {
    const id =
    const slug = tag.node.slug.current
    const category = tag.node.category
    const path = `/${category}/${slug}/`

      component: require.resolve('./src/templates/tag.js'),
      context: { id }
May 11, 2020, 9:15 PM

Sanityโ€“ build remarkable experiences at scale

The Sanity Composable Content Cloud is the 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?

Categorized in