Scott Anderson
Scott Anderson

Reputation: 1371

Tokens for taxonomy term parents in Drupal 8 Pathauto

I am trying to find the correct tokens to use for a Pathauto pattern in Drupal 8.

In Drupal 7, I have a Pathauto module pattern that creates a URL alias with a node's term and parent term.

So if the node had a Term reference of Health -> Diet. The URL would be health/diet/node-title.

The pattern to generate this is [node:field-topic:0:parents:join-path]/[node:field-topic:0]/[node:title]

Note the :0 is because the Term reference field allows multiple values.

Upvotes: 0

Views: 1717

Answers (1)

Scott Anderson
Scott Anderson

Reputation: 1371

Thanks to Berdir here for the help https://drupal.stackexchange.com/questions/224607/tokens-for-taxonomy-term-parents-in-pathauto/224754#224754

The tokens have changed a bit since Drupal 7. See example below.

Token: /articles/[node:field_tags:0:entity:parents:join-path]/[node:field_tags:0:entity]/[node:title]

Tag hierachy: A > B > C

Alias for an article tagged with C: /articles/a/b/c/pathauto-test

Upvotes: 0

Related Questions