Recently I had to generate term-specific aliases (aliases that are different from the default alias pattern set for Article entities). This is how to do it:
1. Enable the Pathauto plugin
2. Set the default URL alias pattern for your content type in order to fire the hook
3. Implement hook_pathauto_alias_alter() in your .plugin file.
Example plugin structure:
myplugin/
– myplugin.info.yml
– myplugin.plugin
– src/
– ArticlePathAlias.php
I like to keep .plugin clean and simple and because of that I store the main logic in src/ArticlePathAlias.php file.
The myplugin.info.yml this is just a regular .info file.
4. Add the following to your myplugin.plugin file:
Source: New feed