Taxonomy term

The taxonomy_term entity: a revisionable, translatable item that content references to classify it, with its own page, parents and permissions.

Learn DrupalDrupal glossary

A taxonomy term is one label inside a Drupal vocabulary, for example Carrots in a vocabulary of ingredients or Germany in a vocabulary of countries. Each term is a content entity with its own ID, a name, a description and a place in the vocabulary's hierarchy. Content points to terms through a reference field, and Drupal gives every term a page that lists what is tagged with it.

How a taxonomy term works in Drupal 11

The entity type is taxonomy_term. Its bundle is the vocabulary, and its ID key is tid. In Drupal 11.4.10 a term is revisionable and translatable, and it has these base fields:

  • name, a required text of up to 255 characters;
  • description, long text with a text format;
  • parent, an entity reference with unlimited values, limited to terms of the same vocabulary;
  • weight, an integer that orders terms in ascending order;
  • status, shown on the form as Published.

The user guide adds that you can attach further fields to a term, such as an icon image. This is the part that separates a term from a plain tag string: it is an entity that can carry its own data.

The term page at /taxonomy/term/{tid} comes from core's taxonomy term view. Its header shows the term in the full view mode, and each row is a piece of tagged content in the teaser view mode. Viewing requires the View published content permission (access content) and a published term; edit and delete rights are granted per vocabulary through permissions such as "Edit terms" and "Delete terms".

Example

Take a vocabulary of ingredients. Under Structure › Taxonomy, choose Add terms for the vocabulary. Create Vegetables, then create Tomatoes and open its Relations section. Choose Vegetables under Parent terms and save. Tomatoes now sits under Vegetables, and the vocabulary's overview page shows the nesting. Both terms get pages at /taxonomy/term/{tid}, and each page lists the content tagged with that term.

Common mistakes

  • Unpublishing a term and expecting visitors to keep the page. Without the administer permission, an unpublished term is not viewable, so its page is closed to anonymous visitors.
  • Using the term name as an identifier. A name can be edited and translated. Code and configuration should refer to the ID or the UUID.

For marketing and content teams

Every term is a ready-made landing page. The page shows the term and the content tagged with it, so a clear name and a useful description matter. Check how each term page looks before you launch a tagging scheme, and use the Published checkbox to hold a term back until it is ready. For the wider picture of vocabularies and reference fields, see taxonomy.

Sources

Questions about Taxonomy term

Drupal deletes children that have no other parent. A child with a second parent stays and only loses the deleted one. The delete form warns that deleting a term deletes all its children. To keep them, give the children a new parent before you delete.

Yes. The parent field accepts unlimited values, so a term can sit under several parents in the same vocabulary. Set the parents in the Relations section of the term form. The overview page does not support dragging a term that has multiple parents.

Each term has a page at /taxonomy/term/{tid}, an edit form at /taxonomy/term/{tid}/edit and a delete form at /taxonomy/term/{tid}/delete. Core's taxonomy term view also provides an RSS feed at /taxonomy/term/{tid}/feed.

To view a term, a user needs the View published content permission and the term must be published. Editing and deleting use permissions set per vocabulary, such as Edit terms and Delete terms. The Administer vocabularies and terms permission allows every operation.

Related terms

All Drupal terms from A to Z