Juggling Taxonomy with Pathauto

Today I was working on a site when I noticed my node paths were incorrect for some of my nodes. Now I heavily use Pathauto in conjunction with Taxonomy to define my paths for everything on the site and this issue hasn't come up before. I swear, I didn't change my Pathauto rules ([termpath-raw]/[title-raw]), so what changed?

After looking at the nodes that have the incorrect path and nodes that have the correct paths I figured out that Pathauto was selecting one of my other taxonomies on the node. The nodes I was working with had multiple Taxonomy Categories that applied to it. Pathauto was simply taking the lightest category that was filled out and using that. So for my nodes that were correct, the first category that was filled out was the one I was planning on using for the path. The incorrect nodes had another category filled out before the one I wanted.
The solution was pretty simple. Adjust the weights of my Taxonomy Categories. I made the category -10 that I wanted to always affect the path of the node. That way it will always be first in my listing on the node creation/edit page. After I adjusted the weight I went into the content view and regenerated the aliases for my nodes (Make sure you adjust your Pathauto settings to Create New Alias, Delete Old - or else you'll get multiple path aliases which will cause the old alias to still work).

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Hi Markus! Thanks for sharing

Hi Markus!

Thanks for sharing your experiences with Pathauto. That's exactly the odd behavior and exactly the solution to it.

One thing I'd suggest is that you take a look at the path_redirect module - http://drupal.org/project/path_redirect - if you install that along side Pathauto then you can set your Update Action to be "Create new alias. Redirect from old alias." which I think is the best because it prevents 404s, prevents multiple aliases for a single node, and ensures that the aliases are an accurate reflection of the current node situation.

Also, maybe consider the comment_notify module on http://drupal.org/project/comment_notify which would send me an e-mail if you respond to this comment ;)

Thanks, I've added

Thanks, I've added comment_notify.

In addition to path_redirect, I also recommend search404 for any aliases that might be missed from outside links. I tend to use this a lot when converting an old site to a Drupal site since most times, the sitemap/paths will change and I don't usually want to manually map over the 100 or so old urls.

-Andrew

User login