Pathauto - Create node URL from taxonomy hierarchy

By xngo on January 19, 2020

In Drupal, you can create a nested hierarchy with your taxonomy terms. For my case, I have the following vocabulary structure.

Drupal 8 - Taxonomy structure

I want the URL to look like

By default, the [node:field_ho_location:entity:parents] token does provide all the parent terms.

Drupal 8 - Pathauto - Pattern

However, it will concatenate each parent term with an hyphen and will generate URL like

Luckily, token module does provide function to manipulate the results. I used :join-path function to replace the hyphen with a forward slash. So, my final pathauto pattern looks like this.


The URL generated is

About the author

Xuan Ngo is the founder of He currently lives in Montreal, Canada. He loves to write about programming and open source subjects.