Skip to main content
2 minutes
How to Create a Custom Taxonomy Term URL Using Drupal 8

In this blog, we are going to create a taxonomy vocabulary in Drupal, Create a URL Alias for the Vocabulary using the Redirect Module, Create a view that renders taxonomy terms, then use the Taxonomy Views Integrator to reference our created Views Page to render the filtered term using pre-configured views arguments.

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
 

News-Type-Category
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;

  

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 (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;

 

Taxonomy-Term-Link-In-Views


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

Taxonomy-Term-Link-IN-URL

 

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
Using the Taxonomy Views Integrator plugin while referencing from the Created Blog Taxonomy Views
Using the Taxonomy Views Integrator plugin while referencing the page from our Created Blog Taxonomy Views

The Ultimate Managed Hosting Platform