Skip to main content
Home
GrN.dk

Main navigation

  • Articles
  • Cases
  • Services
  • Your Digital Project Manager
  • About Greg Nowak
  • Image Gallery
  • Contact
User account menu
  • Log in

Join my community / free newsletter — sign up here

Breadcrumb

  1. Home

Drupal Taxonomy Hierarchy in Views: Practical Ways to Show Nested Terms

Illustrated infographic summarizing: Drupal Taxonomy Hierarchy in Views: Practical Ways to Show Nested Terms

By Greg Nowak. Last updated 2026-07-07.

Showing a taxonomy hierarchy in Drupal Views sounds like a small display request: make the parent terms appear above the child terms, or make a parent category include everything below it. On a real business site, it is rarely just cosmetic. It affects landing pages, resource libraries, service navigation, editorial governance, and how quickly a visitor can move from a broad topic to a useful next step.

The old Drupal 8 version of this problem still matters because many search results and copied snippets were written for that era. The important update is support risk. Drupal 8 reached end-of-life on November 17, 2021. Drupal 10 is scheduled to reach end-of-life on December 9, 2026. So if the site is still on Drupal 8, treat any hierarchy work as migration triage, not as a place to add clever long-term complexity. The same taxonomy ideas still apply, but the implementation decision should be made for supported Drupal 10 or Drupal 11, with Drupal 12 planning close behind.

Start by naming the real job

In project conversations, 'show taxonomy hierarchy in Views' usually means one of several different things. A content team might want a parent term page to include articles tagged with child terms. A UX lead might want a visible tree of terms in a sidebar. An operations team might need depth information for routing, permissions, exports, or reporting. Those are different builds, and mixing them into one View is where Drupal projects get brittle.

Decision matrix for taxonomy hierarchy work in Drupal Views
Requirement Best starting point Main risk
List content tagged with a parent term and descendants Core Views taxonomy term ID with depth behavior Term names change, so ID-based filtering is safer
Render a visible parent-child term tree Custom block, controller, or preprocess code using taxonomy storage Forcing Views to act like a tree renderer
Filter by readable term names with descendant depth Views Taxonomy Term Name Depth module Name-based filters can break during renaming or translation
Use depth in custom logic or templates Taxonomy Term Depth module or custom calculated depth Assuming it will solve Views display by itself

When Views is enough

If the goal is a normal listing page, start with core. Drupal core has long supported hierarchical vocabularies, and the Drupal 11 API still includes a taxonomy Views depth handler. In plain terms: if you can work with term IDs, a View can often retrieve content tagged with a selected term and terms below it. That is the right first check before adding a module or writing code.

For a marketing site, product catalog, knowledge base, or location directory, keep the data model boring and dependable. Use curated vocabularies for navigation-critical topics. Avoid deep hierarchies unless users genuinely browse that way. Do not let free tagging become the source for important landing pages. If editors can rename a term, the View should not depend on that exact public name as its only source of truth.

A practical setup is to use a stable route, alias, or term ID to identify the current category, then let the View handle the content listing. Test the result with a parent that has many children and with an empty branch. Also check multilingual behavior if the site uses translated terms. Many hierarchy bugs are not code bugs; they are unclear editorial rules showing up in the interface.

When custom code is cleaner

If you need to display the terms themselves as a structured tree, custom code is often cleaner than a heavily configured View. Views is excellent for querying and displaying rows of content. It is less pleasant when asked to become a navigation tree, an active-trail system, and a content listing all at once.

Drupal taxonomy storage gives you the right primitives. In current Drupal API documentation, TermStorageInterface exposes helpers such as loadTree(), loadParents(), loadAllParents(), and loadChildren(). For a small custom block or controller, that is usually enough to build a deliberate tree and keep the content View separate.

$term_storage = \Drupal::entityTypeManager()
  ->getStorage('taxonomy_term');

$tree = $term_storage->loadTree('categories', 0, NULL, TRUE);

For production code, inject the entity type manager rather than using \Drupal:: directly. The snippet is useful for orientation, but the maintainable version belongs in a service, controller, block plugin, or preprocess layer where caching, access checks, and translation can be handled explicitly.

This also gives the interface team more control. You can hide empty branches, limit depth on mobile, mark the active trail, decide whether parent terms are links, and cache the tree with the right taxonomy term cache tags. That is usually easier for an agency team to inherit than a single oversized View export full of relationships, grouping rules, and Twig exceptions.

Current contributed options

If core is close but not quite enough, two contributed modules are worth considering in 2026.

Views Taxonomy Term Name Depth adds a Views contextual filter for taxonomy term names with depth and its current stable release works with Drupal 9, 10, and 11. It is useful when the route or editorial requirement is genuinely name-based, for example a readable category path that must include child terms.

composer require 'drupal/views_taxonomy_term_name_depth:^7.3'

Use it with care. Term-name filtering is convenient, but term IDs are still safer for multilingual sites, rebrands, renamed categories, and content operations where editors regularly adjust labels.

Taxonomy Term Depth is a different tool. Its current 3.x release supports Drupal 10.3 and 11, and the project describes a stored depth property for terms. That can help custom code, templates, or reporting that need reliable depth information.

composer require 'drupal/taxonomy_term_depth:^3.0'

It is not a magic switch for turning any View into a perfect taxonomy tree. The project page still frames better Views field, filter, and sort integration as future work, so use it as support for custom implementation rather than as a full display solution.

A practical build checklist

  • Confirm whether the user needs a content listing, a term navigation tree, or both.
  • Use term IDs or stable aliases for logic; treat term names as labels.
  • Keep navigation vocabularies curated and shallow where possible.
  • Separate tree rendering from content listing when the UI becomes complex.
  • Test parent terms, child terms, empty branches, translations, and cache invalidation before launch.
  • Do not add new Drupal 8-only work unless it is clearly part of a short migration bridge.

The best answer is usually not the most elaborate one. Keep taxonomy meaningful, keep Views focused, and add a small custom layer only where the visitor experience genuinely needs a hierarchy. That gives business owners clearer landing pages, gives editors a structure they can manage, and gives future developers a setup they can safely upgrade.

If your taxonomy is carrying navigation, SEO landing pages, or campaign traffic, it is worth reviewing before it grows further. Greg can help map the smallest Drupal taxonomy and Views fix that improves structure without creating a long-term maintenance trap.

Related on GrN.dk

  • Drupal CMS 2.0 Speeds Marketing Site Rebuilds, but It Is Not Autopilot
  • When Google can call the business, your local data stops being cosmetic
  • AI Crawler Control for Business Websites: Protect Content Without Sacrificing Search Visibility

Need help with this kind of work?

Get help with Drupal taxonomy and Views Get in touch with Greg.

Sources

  • Drupal core release schedule
  • Drupal API: TaxonomyIndexTidDepth
  • Drupal API: TermStorageInterface
  • Views Taxonomy Term Name Depth
  • Taxonomy Term Depth
Last modified
2026-08-12

Tags

  • Drupal
  • Drupal 8
  • Drupal 10
  • Drupal 11
  • Views Taxonomy

Review Greg on Google

Greg Nowak Google Reviews

 

Written recommendations from Trafik og Veje, Aarhus Municipality (2011) and AgroTech (2010) — read them on LinkedIn.

Illustrated infographic summarizing: From Supplier Invoice to Bookkeeping: AI with a Control Checkpoint
From Supplier Invoice to Bookkeeping: AI with a Control Checkpoint
2026-08-18

AI can reduce the work involved in processing supplier invoices, but reliable bookkeeping requires validation, duplicate checks, approval and a clear audit trail.

Illustrated infographic summarizing: Nginx 1.30 Changed the Upstream Defaults—Test Before You Upgrade
Nginx 1.30 Changed the Upstream Defaults—Test Before You Upgrade
2026-08-17

Nginx 1.30 defaults upstream proxying to HTTP/1.1 with keepalive enabled. Here is what to inspect, model and test before upgrading.

Illustrated infographic summarizing: OpenAI’s Assistants API Shuts Down in Ten Days. Is Your App Ready?
OpenAI’s Assistants API Shuts Down in Ten Days. Is Your App Ready?
2026-08-16

OpenAI’s Assistants API shuts down on August 26, 2026. Learn what to inventory, how to preserve state and how to cut over without breaking the product.

Illustrated infographic summarizing: WordPress 7.1 Forces the Editor Into an iframe—Test Your Custom Blocks
WordPress 7.1 Forces the Editor Into an iframe—Test Your Custom Blocks
2026-08-15

WordPress 7.1 removes the non-iframe editor fallback. Learn how to audit custom blocks, test real workflows and fix compatibility issues before launch.

Illustrated infographic summarizing: GitHub will stop sending jobs to stale self-hosted runners
GitHub will stop sending jobs to stale self-hosted runners
2026-08-14

GitHub starts enforcing runner versions on August 24, 2026. Audit and upgrade self-hosted runners before builds and deployments start stalling.

Illustrated infographic summarizing: Your AI Agent Has Shell Access. What Can It Reach?
Your AI Agent Has Shell Access. What Can It Reach?
2026-08-13

A practical guide to mapping what a shell-enabled AI agent can reach, then containing its access to files, credentials, networks, tools, and high-impact actions.

Illustrated infographic summarizing: Cloudflare Changed DoH JSON. What Else Is Parsing DNS as Text?
Cloudflare Changed DoH JSON. What Else Is Parsing DNS as Text?
2026-08-12

Cloudflare’s DoH JSON change exposes brittle DNS parsing. Find affected scripts, test both formats, and choose a safer integration contract.

Illustrated infographic summarizing: Your Website Can Answer Questions Now. Should It?
Your Website Can Answer Questions Now. Should It?
2026-08-11

NLWeb makes conversational website search practical to deploy. The real question is whether your content, users and team are ready to support it.

Illustrated infographic summarizing: AI Search Finally Has Reports. Now Connect Visibility to Revenue
AI Search Finally Has Reports. Now Connect Visibility to Revenue
2026-08-11

Google and Bing now expose first-party AI search data. The real task is connecting citations and impressions to analytics, CRM outcomes, and revenue.

Illustrated infographic summarizing: The Bot Passed Your CAPTCHA. What Did It Do Next?
The Bot Passed Your CAPTCHA. What Did It Do Next?
2026-08-11

Passing a challenge is only one signal. Session analysis, server-side validation and endpoint-specific controls help reduce bot abuse without blocking customers.

More articles

Built by AI — available for your business. The daily articles on this site are researched, written and illustrated by an autonomous AI pipeline. At nowa.dk I install the same kind of AI automation in businesses at fixed prices — site in Danish, English version here, and web/marketing agencies have a dedicated page.

RSS feed

Footer

  • All articles
  • Contact

GrN.dk — AI automation, web platforms, web optimization, data handling and logistics.

© 2026 GrN.dk · LinkedIn · Contact · AI automation in Danish: nowa.dk

Behind GrN.dk: Individual Entrepreneur Codecrafter · Tax ID 305669096 · Bakhtrioni St. 22, 0194 Tbilisi, Georgia · official business register