Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

sanity-plugin-taxonomy-manager

andybywire2.9kMIT3.3.1TypeScript support: included

Create and manage SKOS compliant taxonomies, thesauri, and classification schemes in Sanity Studio.

sanity, sanity-plugin, SKOS, taxonomy, thesaurus

readme

Sanity Taxonomy Manager

NPM Version License

Create and manage SKOS compliant taxonomies, thesauri, and classification schemes in Sanity Studio.

taxonomy manager plugin screenshot

Documentation

For full documentation, visit sanitytaxonomymanager.com.

Features

  • Adds two document types to your Sanity schema which are used to generate SKOS compliant concepts and taxonomies: skosConcept and skosConceptScheme
  • Includes reference filter helpers to allow you to easily include a specific taxonomy, or particular branch of a taxonomy in your Sanity documents
  • Encourages taxonomy and thesaurus design best practices by enforcing disjunction between Broader and Related relationships and disjunction between Preferred and Alternate/Hidden labels
  • Standards compliant architecture means that taxonomy terms and structures can be migrated to standards compliant standalone tools when you need higher level taxonomy and knowledge graph support.

Installation

In your Sanity project folder, run

npm i sanity-plugin-taxonomy-manager

or

yarn add sanity-plugin-taxonomy-manager

Configuration

Add the plugin to your project configuration to add the Taxonomy Manager Tool to your studio workspace.

// sanity.config.js

import {defineConfig} from 'sanity'
import {structureTool} from 'sanity/structure'
import {taxonomyManager} from 'sanity-plugin-taxonomy-manager'
import {schemaTypes} from './schemas'

export default defineConfig({
  name: 'default',
  title: 'Sanity Studio',
  projectId: '<projectId>',
  dataset: 'production',
  plugins: [
    structureTool(),
    // Include the taxonomy manager plugin
    taxonomyManager({
      // Optional: Set a Base URI to use for new concepts & concept schemes
      baseUri: 'https://example.com/',
      // Optional: Use `customConceptFields` and `customSchemeFields` keys to add custom fields to Concept or Concept Scheme document types
      customConceptFields: [
        {
          name: 'sameAs',
          title: 'Same As',
          type: 'url',
          description:
            'Specify a fully qualified IRI that identifies the same concept in another vocabulary',
        },
      ],
    }),
  ],
  schema: {
    types: schemaTypes,
  },
})

The plugin adds skosConcept and skosConceptScheme document types to your studio. Use a filter on documentTypeListItems in the desk tool configuration to exclude taxonomy manager document types from your main document view.

// sanity.config.js

import {defineConfig} from 'sanity'
import {structureTool} from 'sanity/structure'
import {taxonomyManager} from 'sanity-plugin-taxonomy-manager'
import {schemaTypes} from './schemas'

export default defineConfig({
  name: 'default',
  title: 'Sanity Studio',
  projectId: '<projectId>',
  dataset: 'production',
  plugins: [
    structureTool({
      structure: (S) =>
        S.list()
          .title('Content')
          .items([
            ...S.documentTypeListItems().filter(
              (listItem) => !['skosConcept', 'skosConceptScheme'].includes(listItem.getId())
            ),
          ]),
    }),
    taxonomyManager(),
  ],
  schema: {
    types: schemaTypes,
  },
})

Contributing

Community collaboration is highly encouraged. To make sure your contributions are aligned with project goals and principles, please read the contributing docs before submitting a pull request.

Component Diagrams

The following diagrams map out the relationships between the components used in this plugin and are intended to help those interested in contributing to the project orient themselves. The Taxonomy Manager tree view is designed to support polyhierarchy, and to provide UI affordances common to other taxonomy management tools, both of which lend some complexity to the component structure.

[!TIP] You do not need to understand any of this to use the plugin!

<Summary>

Tree View

</Summary>

The Tree View component creates the user interface for interacting with a given taxonomy (SKOS Concept Scheme) visually in the Sanity Structure tool.

graph BT
    subgraph SchemeContext.Provider
      direction BT
      Hierarchy.tsx-->TreeView.tsx
      subgraph TreeContext.Provider
        direction BT
        TreeStructure.tsx-->Hierarchy.tsx
        TopConcepts.tsx[
          TopConcepts.tsx
          <i style="color: gray; font-size: small">uses SchemeContext</i>
          <i style="color: gray; font-size: small">uses TreeContext</i>
        ]-->TreeStructure.tsx
        Orphans.tsx[
          Orphans.tsx
          <i style="color: gray; font-size: small">uses SchemeContext</i>
          <i style="color: gray; font-size: small">uses TreeContext</i>
        ]-->TreeStructure.tsx


        %% Sequence below maintains RTL ordering:
        ConceptDetailLink.tsx-->TopConcepts.tsx
        ConceptDetailLink.tsx-->Orphans.tsx

        ChildConcepts.tsx-->TopConcepts.tsx
        ChildConcepts.tsx-->Orphans.tsx
        Children.tsx-->ChildConcepts.tsx

        ConceptDetailDialogue.tsx-->Orphans.tsx
        ConceptDetailDialogue.tsx-->TopConcepts.tsx

        ConceptDetailLink.tsx-->Children.tsx
        ConceptDetailDialogue.tsx-->Children.tsx
      end
    end
<Summary>

Input Components

</Summary>

The ReferenceHierarchyInput and ArrayHierarchyInput components afford a field-level hierarchical browse and selection experience for taxonomy terms. Both components draw on filter options supplied by the schemeFilter and branchFilter helper functions.

graph BT
    subgraph Input Components
      direction BT
      TreeView.tsx-->ArrayHierarchyInput.tsx[
        ArrayHierarchyInput.tsx
        <i style="color: gray; font-size: small">requires schemeFilter</i>
        <i style="color: gray; font-size: small">or branchFilter helper</i>
        ]
      TreeView.tsx-->ReferenceHierarchyInput.tsx[
        ReferenceHierarchyInput.tsx
        <i style="color: gray; font-size: small">requires schemeFilter</i>
        <i style="color: gray; font-size: small">or branchFilter helper</i>
      ]
      subgraph SchemeContext.Provider
        InputHierarchy.tsx-->TreeView.tsx
        subgraph TreeContext.Provider
          direction BT
          TreeStructure.tsx-->InputHierarchy.tsx
          TopConcepts.tsx[
            TopConcepts.tsx
            <i style="color: gray; font-size: small">uses SchemeContext</i>
            <i style="color: gray; font-size: small">uses TreeContext</i>
          ]-->TreeStructure.tsx
          Orphans.tsx[
            Orphans.tsx
            <i style="color: gray; font-size: small">uses SchemeContext</i>
            <i style="color: gray; font-size: small">uses TreeContext</i>
          ]-->TreeStructure.tsx
          ChildConcepts.tsx-->TopConcepts.tsx
          ChildConcepts.tsx-->Orphans.tsx
          Children.tsx-->ChildConcepts.tsx
        end
      end
    end

License

MIT © Andy Fitzgerald See LICENSE

changelog

📓 Changelog

All notable changes to this project will be documented in this file.

The format of this document is based on Keep a Changelog, and this project adheres to Semantic Versioning.

3.3.1 - 2025-05-29

Fix

  • fix slow branch query by grouping broader lookups (thanks @smundro!)

3.3.0 - 2025-04-08

Fix

  • fix a bug in filter resolution that was preventing the execution of field-level copy and paste actions

Feature

  • simplify filter helper configurations
  • improve Studio configuration messaging

Chore

  • improve error checking

Docs

  • update filter helper and input component documentation
  • add input component structure documentation (Mermaid)
  • improve inline (ts.doc) documentation
  • add ts.doc configuration examples

3.2.9 - 2025-03-13

Fix

  • Add dark mode support for hierarchy input component

3.2.8 - 2025-03-11

Fix

  • Fix concept link and button usability in dark mode.
  • Correct History Note description type (skosConcept)

3.2.7 - 2025-02-12

Fix

  • Fix .length detection bug that was causing the ArrayHierarachicalInput component to crash with flat schemes

3.2.6 - 2024-12-07

Fix

  • Typo in Concept Scheme description

3.2.5 - 2024-11-02

Fix

  • Fix term double-entry in tree view when there are unsaved edits

3.2.4 - 2024-09-30

Added

  • Hierarchical input component for array fields
  • Array input component documentation

Fix

  • Documentation formatting bug

3.2.3 - 2024-09-27

Added

  • Add "done" control to close scheme concept editing controls

Fix

  • Debug new scheme creation guides
  • Fix concept editing controls icon hover color

Chore

  • Update packages

3.2.2 - 2024-09-18

Chore

  • Remove concept management controls boolean (not needed since v.2)
  • Add custom input component to prevent current users from encountering a schema error

3.2.1 - 2024-09-15

Chore

  • Modularize & deduplicate hierarchy input components
  • Improve inline comments & TSDoc
  • Modularize, organize & tighten code

3.2.0 - 2024-08-29

Added

  • Support for custom fields for SKOS Concepts
  • Support for custom fields for SKOS Concept Schemes
  • Documentation for adding custom fields

3.1.5 - 2024-08-24

Chore

  • Update deskTool to structureTool

3.1.4 - 2024-08-24

Chore

  • Update packages & dependencies

3.1.3 - 2024-03-15

Chore

  • Upgrade styled-components

3.1.2 - 2024-03-15

Fixed

  • Add missing peer dependencies, remove unused packages

3.1.1 - 2023-12-03

Added

  • Add hierarchy input component use instructions to documentation

Changed

  • Optimized tree view query for speed

3.1.0 - 2023-11-05

Added

  • Add Hierarchy Input Component support for reference fields using schemeInput() and branchInput() filter helpers

Changed

  • Tree View edit controls are no longer activated via the Concept Management Controls boolean; these now rely on state. (Boolean to be removed in a future iteration)

Fixed

  • Removed "live edit" behavior: changes made to concept schemes from the Tree View now create draft documents
  • Remove unnecessary circular dependencies

[3.1.0-beta.2] - 2023-10-03

Added

  • Add informational Top Concept element to Hierarchy Input component

3.1.0-beta.0 - 2023-10-02

Added

  • Beta release of hierarchical reference input component picker

3.0.2 - 2023-09-13

Changed

  • Improve TS Doc descriptions for branch & scheme filters

3.0.1 - 2023-06-29

Fixed

  • Update homepage URL for NPM README

3.0.0 - 2023-06-28

Added

  • Standalone tool pane in Sanity Studio
  • Additional taxonomy building instructions to Docs
  • Contributing section to Docs
  • Documentation for upgrade paths for schemas still using v1.0 configurations

Removed

  • Support for some baseUri and skosConceptScheme fields created with v1.0 schema

2.3.1 - 2023-06-25

Added

  • Document upgrade notice for schemas still using v1.0 configuration

2.3.0 - 2023-06-12

Added

  • Collapse / expand functionality to tree view
  • Keyboard and screen reader support for collapse/expand, editing actions, and detail links
  • Clarify types and parameters for plugin and helpers
  • Add standalone documentation site
  • Add progressive disclosure to description fields and improve SKOS Concept field descriptions

2.2.2 - 2023-06-06

Added

  • Specification of Base URI in plugin configuration in sanity.config
  • Concept ID generator (for concepts and schemes using previous versions)
  • Reference filter helpers

2.2.1 - 2023-06-01

Added

  • Add informational dialogues to taxonomy terms when definition, example, or scope note content is available.

2.2.0 - 2023-05-29

Added

  • Concept links to hierarchy view
  • "Add top concept" and "add concept" functionality to hierarchy view
  • Description to Tree View pane
  • "Add Child Concept" functionality to concepts in hierarchy view
  • "Remove Concept" functionality to concepts in hierarchy view
  • Title and description guidance and functionality in hierarchy view

2.1.0 - 2023-05-10

Added

  • Base URI field to skosConceptScheme
  • Add History, Editorial, and Change Notes
  • Add detailed descriptions and examples for Note fields

Changed

  • Improved Base URI field description content and formatting

2.0.6 - 2023-05-04

Added

  • Add Tree View validation of 5 level hierarchy limit
  • Add icons and messaging for schema concepts over 5 levels deep
  • Add "getting started" messaging for new Concept Schemes
  • Add "keeping going" messaging for Concept Schemes with no concepts yet assigned.

2.0.5 - 2023-05-01

Fixed

  • Bug in hierarchy tree that caused it to be rendered twice.
  • Issue with style forced the use of inline styles (converted to Styled Components)

Changed

  • Modularized hierarchy tree components

2.0.4 - 2023-03-19

Added

  • Add detail for Preferred Label and Base IRI usage to README.

2.0.3 - 2023-02-04

Added

  • Revise Concept preview subtitle to show immediate broader term(s) only.

2.0.2 - 2023-01-29

Added

  • Support for single level concept schemes with no designated topConcept: Handle absence of topConcepts and omit 'orphan' label when no topConcept is present
  • Data specific Types for components & schema definitions

2.0.1 - 2023-01-21

Fixed

  • Improved taxonomy tree effect to eliminate extra delay in fetching from the content lake.

2.0.0 - 2023-01-16

⚠ BREAKING CHANGES

  • This version no longer works in Sanity Studio V2

Added

  • Initial Sanity Studio V3 release

2.0.0-beta.0 - 2023-01-16

Added

  • Beta Sanity Studio V3 release

1.0.5 - 2022-11-23

Fixed

  • README link that was not behaving as intended across applications.

1.0.4 - 2022-10-20

Fixed

  • Taxonomy Tree CSS was spilling over into description fields for the studio. Added unique classes to keep plugin styling from being too enterprising.

1.0.3 - 2022-09-29

Fixed

  • Concept Scheme Tree View bug that caused by missing parent document value on first render.

Changed

  • Improved taxonomy scheme field descriptions.

1.0.2 - 2022-09-28

Fixed

  • Fixed bug introduced by Sanity Studio update 2.33.0 that made parent unavailable to custom components directly.

Changed

  • Made concept scheme assignment async to improve consistency of Concept Scheme Tree View rendering.

1.0.1 - 2022-06-12

Added

  • Add "Concept Scheme Tree View" custom component to Taxonomy Schemes view. List shows hierarchy, Top Concepts, orphans, and polyhierarchial concepts.

1.0.0 - 2022-04-01

Added

0.2.0 - 2022-03-22

Added

  • Move "Settings" data into config.json, update initial value fields/functions, and remove "Taxonomy Settings" document scheme

0.1.0 - 2022-03-17

Added

  • Tag initial development release
  • Update README with installation, basic use instructions, and development warning
  • Add changelog
  • Migrate SKOS Taxonomy Management schemas from local development branch to (this) plugin repository