How to Create a Custom Taxonomy Term URL Using Drupal 8,9 and 10

By Thomas Kaisuka | | Updated On: Wed, 05/24/2023 - 19:10

How to Create a Custom Taxonomy Term URL Using Drupal 8

The first Step Here is to ensure you have TVI (Total Views Inetegrator) installed. Reason i love this module is that it gives you ability to customize views displays, listing each taxonomy vocabulary or term or even children of parent terms in a Drupal Views page display with its own customized URL. Remember to have the module installed using composer together with the Redirect Module and Pathauto module to get desired results.

This gives taxonomy terms having their own urls a meaning.

Taxonomy Views Integrator In Action
Taxonomy Views Integrator In Action


Okay, let's proceed to the Nitty Gritty Of This Post;
Using the Redirect Module  one can construct a URL Alias pattern per taxonomy vocabulary. This will be taken on by the terms and sub-terms of the particular taxonomy vocabulary of interest.

Lets look at our "News Type" Vocabulary for example; (You'll notice that label has Blog Category not News Type which was my original naming and hence will be the machine name). That shouldn't be an issue since any label you provide shall become the url alias name (token name: [term:vocabulary]) as will be shown later in the example here

This is my News Type Vocabulary


Sample Screenshot TERM URL
When i edit the news term it will give me options to either do a custom URL or configure a URL pattern that will make a uniform pattern for all other terms in this vocabulary


Lets now create a URL pattern for our News Type (Blog Category) vocabulary;
 - Go to configuration > search and metadata > URL aliases and configure a URL pattern;









Remember to hit the save button. In the illustration below, you can see the saved URL pattern in the red box below




You can now reference the Taxonomy vocabulary in any entity type (In this example the default article content type) to categorize your content.

In this case as you can see in this blog, i used the Drupal Byte term under my news type (labelled blog categorization) vocabulary and the results were as follows;



The resulting URL is in the Red Box Below



As per how TVI (Taxonomy View Integrator) Module works, i duplicated the defualt Taxonomy Term View and used it as my to customize the display of this particular vocabulary 

Duplicated-Taxonomy term View

The Ultimate Managed Hosting Platform