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

Type Taxonomy Setup & Use

By Andy Fitzgerald

Type taxonomies are a crucial tool for organizing digital content for findability and discovery. Product catalogs, services listings, resource types, and subject hierarchies are all commonly characterized by "type" organization: each child category describes a more specialize type of thing than the parent category. Well defined type taxonomies area powerful tool for making your content more discoverable and reusable across contexts.

In this guide you'll learn what makes "type" taxonomies different from other kinds of taxonomy structures, like topic or faceted taxonomies, and will learn how to set up a type taxonomy in the Sanity Taxonomy Manager plugin. You'll also see examples of how to integrate your taxonomy into document schemes and query across related concepts for tagged documents.

Examples of type taxonomies (clockwise from top-left): The Open Eligibility Project (human services), Elemeno Health (resource types, using the Sanity Taxonomy Manager plugin), National Geographic (education subjects), REI (product categories)

Type classification helps users navigate and browse categories from general to more specific and narrow down large content sets to specific items that meet their needs. It also allows information designers to assemble related content into meaningful collections and to provide richer search results based on parent/child relationships.

When combined with search term and traffic data, type taxonomies help you to draw deeper insight from visitor behaviors, and they can play a vital role in providing AI the ground truth it needs to return reliable, trustworthy results.

Key Features

  • Relationships: Type taxonomies organize concepts in "is-a" relationships: "Nutrition Education" is a type of "Health Eduction," which is a type of "Education." These relationships, when consistently maintained, help users to confidently navigate categories, and can allow algorithms to accurately draw inferences about resources tagged with taxonomy terms.
  • Adaptability: Type taxonomies can be tailored to a wide range of specific content collections or subject domains.
  • Flexibility: Type taxonomies can be used to add structure to simple domains with only a handful of concepts, or can scale to many thousands of terms.

Setting Up a Type Taxonomy

1. Install Sanity Taxonomy Manager

Gotcha

These instructions assume you have already identified a taxonomy to adopt or adapt, or have designed one for your specific content needs. Taxonomy provisioning and creation is beyond the scope of this guide, but you can find a primer on finding and designing taxonomies in the Sanity Taxonomy Manager docs.


The Taxonomy Manager plugin allows you to create standards compliant relationships that help keep your taxonomy interoperable and reusable.

2. Create a new concept scheme

Concept Schemes are used to create multiple taxonomies in a single project, and, where needed use the same concepts across them. This gives you a single source of truth for each concept you define, and allows you to establish semantic relationships between individual taxonomies.

Add a new Concept Scheme with either the global "new document" button, or the "new document" button in the Concept Schemes list view

3. Name and describe your taxonomy

Add a clear name and describe the purpose and goals of your taxonomy to users. Tagging content with managed terms may be new to your content creators: good descriptions can help users understand why the tagging step is important.

Protip

Describe what your taxonomy is for, as opposed to only what it is of: a taxonomy of a topic may feel superfluous; a taxonomy for a purpose can help bring authors and collaborators along.

4. Add top concepts

Top Concepts are the entry points to your type hierarchy. While creating top concepts is not strictly required, using them can help you follow good modeling practices (by calling out "orphans" and showing unbalanced structures) and gives you more options for filtering terms and querying tagged content.

Protip

Include definitions and examples as you go.

5. Add child concepts

Child concepts are the narrower types in your taxonomy. To create a consistent "is-a" hierarchy, you should be able to say that "[child concept] is a [parent concept]."

Gotcha

Sanity Taxonomy Manager supports up to 5 levels of hierarchy. This is for performance and to help ensure semantic integrity,

6. Add the taxonomy to a Sanity document scheme

You're now ready to publish your taxonomy, integrate it into your content scheme, and start tagging content. Taxonomy Manager includes two helper functions for ensuring that only the appropriate concepts are available for a given field:

Querying Content

Once your content is tagged, the semantics built into your type taxonomy allow you to retrieve content based on single concepts, or on relationships between concepts.

Get content tagged with a concept by prefLabel

*[_type == "post" && subject->prefLabel == "Anthropology"]

Gotcha

Querying by prefLabel is convenient in some situations, but if your labels ever change, you'll need to rewrite all your queries. You can write more resilient code by querying by conceptID.

Get content tagged with a concept by conceptID

*[_type == "post" && subject->conceptId == "8a60d3"]

Each concept you create in Taxonomy Manager is automatically given a unique conceptId. You can find the conceptId below the Base URI field in the concept editor pane:

Each concept has a unique ID you can use to query and reference concepts

Protip

Taxonomy Manager's conceptId allows you to reuse and reference the same Concepts and Concept Schemes across studios and datasets.

Get content tagged with the child concepts of a specified concept

*[_type == "post" && 
  subject->conceptId in 
    *[_type == "skosConcept" && "8a60d3" in broader[]->conceptId].conceptId
]

Get content tagged with a concept and content tagged by child concepts of that concept

*[_type == "post" && 
  subject->conceptId == "8a60d3" ||
  subject->conceptId in 
    *[_type == "skosConcept" && "8a60d3" in broader[]->conceptId].conceptId
]

Well defined, standards compliant taxonomy provides a ground truth foundation for scores of different discovery, personalization, and business intelligence applications. The queries above offer just a few examples of how assiduously applied taxonomy can help you manage content based on the relationships you've created. Your dataset, taxonomy, and goals will be the most natural drivers for how your taxonomies are used to create value.

Learn More

Find more examples, applications, and tips in the Sanity Taxonomy Manager Docs >>

Sanity – build remarkable experiences at scale

Sanity Composable Content Cloud is the headless CMS that gives you (and your team) a content backend to drive websites and applications with modern tooling. It offers a real-time editing environment for content creators that’s easy to configure but designed to be customized with JavaScript and React when needed. With the hosted document store, you query content freely and easily integrate with any framework or data source to distribute and enrich content.

Sanity scales from weekend projects to enterprise needs and is used by companies like Puma, AT&T, Burger King, Tata, and Figma.

Other guides by author

Search Taxonomy Setup & Use

Search taxonomies (or thesauri) are crucial tools in ensuring that your site search feature gets users where they want to go.

Andy Fitzgerald
Go to Search Taxonomy Setup & Use

Faceted Taxonomy Setup & Use

Faceted taxonomies are a great option for organizing resources that don't fit neatly into hierarchical structures.

Andy Fitzgerald
Go to Faceted Taxonomy Setup & Use

Topic Taxonomy Setup & Use

Add topic-based relationships to your content to make it more discoverable and reusable across contexts.

Andy Fitzgerald
Go to Topic Taxonomy Setup & Use

Self-Hosting Sanity Studio with GitHub Actions

A comprehensive guide to self-hosting Sanity Studio on DreamHost with GitHub Actions for continuous integration.

This is an external link at:www.andyfitzgeraldconsulting.com
Andy Fitzgerald
Go to Self-Hosting Sanity Studio with GitHub Actions