How do I use Taxonomy reference field tokens in a path alias? I have a content type with two taxonomy entity reference fields. Both are required fields that only allow one value. I have path_auto and token enabled. I would like to use them to set the path of the node type.

This is the path pattern that is a problem:

[node:field_main_site_section:entity:name]/[node:field_content_category:entity:name]/[node:title]

It looks close to the answer given in another questionn here.

Result: The only thing showing up in the path is the title.

Versions: Drupal 8.8.5, pathauto 1.8, token 1.7

What have I tried?

I tried running the code through the debugger and found out that the action is in the functions PathautoGenerator::createEntityAlias() and Token::generate(). I see that the three tokens are found and that a Node data is passed to Token generate. Then the generate function runs $replacements = $this-&gt;moduleHandler-&gt;invokeAll('tokens', [$type, $tokens, $data, $options, $bubbleable_metadata]). There were 9 modules found that implement hook_tokens but the only one returning any data is node_tokens. Looking at that code I don't see any attempt to return fields.

I also found an issue on the token module that indicated that I might be missing Token view modes. I was indeed missing a token view mode for my two taxonomy vocabularies so I created them. I added each field in the vocabulary including "name" in plain text.

I also tried to guess that the node needed to be converted to an entity to grab it's fields:

[node:entity:field_main_site_section:entity:name]/[node:entity:field_content_category:entity:name]/[node:title]

That was an invalid pattern. 

Question:
What is the correct pattern or what else do I need to configure?
Solved by two changes:


Apply the patch from this Token issue, "Inconsistent loading of third party hook implementations"
Make sure Token display mode exists for each taxonomy vocabulary


I tested and confirmed that both the patch and the display mode config changes were needed.