🗓️ Everything *[NYC] is back. A free gathering for AI builders. Sept 9 →

How to group documents in Sanity - use Parent/Child relationship?

9 repliesLast updated: Nov 29, 2025

Is there a way to group documents? I have something for categories where I followed the Parent/Child relationship guide . I guess I just follow that anytime I want something to be grouped?
AI Update

There are several ways to group documents in Sanity, and the approach you choose depends on your specific use case:

Parent/Child Relationships with References

Yes, the parent/child relationship pattern you're already using for categories is a solid approach for grouping! This involves using reference fields to create hierarchical structures. You can implement this either:

The key thing to understand is that references are bidirectional when querying with GROQ, but they only appear in the Studio UI where you define the reference field. So if you want editors to manage the relationship when editing categories, put the reference field on the category document. If it makes more sense to assign categories when editing posts, put the reference on the post.

Other Grouping Approaches

Depending on your needs, you might also consider:

The parent/child reference pattern is definitely a versatile solution you can reuse for different grouping scenarios. The hierarchies and graphs guide has more details on modeling these relationships, and remember you can use GROQ's -> operator to traverse references in either direction when querying your content.

Show original thread
9 replies

Was this answer helpful?

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.

Related contributions