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

By Thomas Kaisuka | | Updated On: Mon, 12/05/2022 - 08:21

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 with its own customized URL

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 no matter what my new label is to avoid messing up the site URLS in future)
 

News-Type-Category
This is my News Type Vocabulary



-------------------------------------

Sample Screenshot TERM URL
When i edit the news term it gives 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;

  

Create-Taxonomy-URL-Pattern-1


-------------------------------------

 

Create-Taxonomy-URL-Pattern-2

 



-------------------------------------
 

Create-Taxonomy-URL-Pattern-4

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


-------------------------------------

Create-Taxonomy-URL-Pattern-5

 


You can now reference the Taxonomy vocabulary in any entity 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 (blog categorization) vocabulary and the results were as follows;

 

Taxonomy-Term-Link-In-Views


The resulting URL is in the Red Box Below
-------------------------------------
 

Taxonomy-Term-Link-IN-URL

 

The Ultimate Managed Hosting Platform