I've just started with Drupal and I'm trying to create the following URL structure with PathAuto and Entity Reference:

Category A -> Category B -> Category C

Resulting in


For display purposes, I have to define the entity reference on the parent entity. IE:

On Category A, define an entity reference to nodes of Category B.

However, in PathAuto it appears that I can only reference child entities, not parent entities.

I have referenced this article (Path alias tokens and node references) which describes the solution if the entity reference is defined on the child, not the parent.

Is there any way to achieve the above?

1 Answer 1


I came across this post when facing the same situation so I am posting the solution I found in case someone else needs it.

The only way I found to solve this was declaring a custom token using hooks. This post was really helpful: https://drupal.stackexchange.com/a/78498

Once both hooks are implemented, you will only need to manually load the parent to get the data you need, whether it is the parent URL or the parent title. After that, just use the token you just created and voilá!

Hope it helps!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.