Best approach for updating URL Alias when moving a taxonomy term

Created on 14 March 2025, 22 days ago

Problem/Motivation

Hi,

I’m working on the Taxonomy Manager contrib module to allows users to move taxonomy terms from one vocabulary to another. This is the issues: https://www.drupal.org/project/taxonomy_manager/issues/2799359 📌 Move terms to different vocabulary Needs work

After moving a term, I need to update its URL alias to reflect the new vocabulary while ensuring it follows the existing Pathauto patterns.

Currently, I’ve tried setting $term->path->pathauto = PathautoState::CREATE; before saving the term, but it doesn’t seem to regenerate the alias. I also considered manually generating and setting an alias, but I’d prefer to use Pathauto’s built-in logic to ensure consistency.

Would it be advisable to call Pathauto’s batch alias update function for taxonomy terms at the end of the process? If so, what’s the best way to trigger it programmatically for the affected terms?
Or is there a better approach to ensuring the alias updates correctly after a term is moved?

Any guidance or best practices would be greatly appreciated!

Thanks!

💬 Support request
Status

Active

Version

1.0

Component

Code

Created by

🇺🇸United States torfj Seattle, WA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024