How to make conditional path aliases? In Drupal 8 you can create path aliases by going to: admin/config/search/path/patterns/add

Which allows me to, for example, say that all content of type "blog_post" can have something like this:

/blog/[category]/[title]


The problem is, I want the TOP path to be different, depending on the category. Specifically, I want any blog post that has the category = Competition, to have:

/competitions/[title]


While still being able to have

/blog/[category]/[title]


I can't seem to get this going. Is there a way to do this? I tried creating another aliases but I don't think there is any path I can specify that will give me this?
Solution 1: Without code


Configure a taxonomy vocabulary named Blog category to manage blog categories.
Configure Blog category aliases to /blog/[term:name].
For the Competitions term, override the URL alias to /competitions.
Configure a taxonomy term reference field (preferably single value) on the Article content type. Say, the field name is field_category.
Configure the Article path pattern as /[field_category:entity:url:path]/[node:title].


This is somewhat like what gapple has mentioned above.

Solution 2: With code


Configure a taxonomy vocabulary named Blog category to manage blog categories.
Configure a taxonomy term reference field (preferably single value) on the Article content type. Say, the field name is field_category.
Configure the Article path pattern as /blog/[field_category:entity:name]/[node:title]
Use hook_pathauto_pattern_alter() or hook_pathauto_alias_alter() to change the path pattern depending on the $context.


This is what I did for my problem. This way, you can choose whatever alias you want for your taxonomy term.