Drupal Pathauto URL Aliases Settings

The Drupal pathauto module is great but be careful how you configure it. The recommended settings are already chosen by default but let's review them below. To get to the Drupal pathauto URL aliases settings, go to: Administer > Site Building > URL Aliases (admin/build/path/pathauto).

1) General Settings

a) Verbose - good idea to keep this on so you know if the alias was created properly

b) Separator - dash is pretty standard and readable though I've seen people use underscores

c) Character case - looks cleaner to stick with all lowercase (but when creating browser titles (page titles) for your nodes, it's good to use mixed case for better readability)

d) Maximum alias length - keep to 100 or less so your urls won't be too long

e) Maximum component length - although the recommended number is 100, I don't imagine you are going to have a word that long, so something much shorter seems more realistic. Perhaps 30.

f) Maximum number of objects to alias in a bulk update - doesn't matter if you aren't doing bulk updates. If your site isn't live yet, the number can be high since it won't matter that it takes a long time to do.

g) Update action - this is a tricky one. If you are only in development mode (site isn't live) and plan changing node titles and/or autonodetitle rules regularly, then I would stick with:

"Create new alias. Delete old alias"

Note that if you are hand-coding links to nodes within other nodes, the safest way in this case would be to only ever use the node/xxx for the href but then that causes problems with SEO since you really always want to use the same link throughout the site. One solution to this is the pathfilter module.

If the site is live and you are careful about creating your node titles, then you can use:

"Do nothing. Leave the old alias intact."

This is so that your node urls don't change even if you later change the node titles.

If you prefer that your urls *always* reflect the node title, then you should choose:

"Create a new alias. Redirect from old alias."

This will ensure that Google, etc. will find your new URL by getting redirected from the old one.

The only other option is:

"Create a new alias. Leave the existing alias functioning."

which is very dangerous since it could end up generating tons of "duplicate content" on your site. You should never have two URLs that show the same exact content. Redirecting from one URL to the other is fine though the best is to only have one URL for each page on the site.

It would be nice to have finer control over this behavior so that you could have it regenerate the alias for a particular node without having to change the default settings. Or perhaps, for unpublished nodes, it could continue to change the url since it's not live.

h) Transliterate prior to creating alias - I had trouble with this one previously but maybe it's working properly now. The idea is if you have special characters in your node title, that these will be replaced with a non-special character equivalent (e.g. n with tilda becomes just n). When I tried this out, it didn't work and ended up putting the node I tried it with in some weird state and generating errors. It could have been since I created the node first and then turned on this feature. Maybe I'll try to reproduce this later on for another article.

i) Reduce strings to letters and numbers from ASCII-96 - same idea as (h) but more restrictive

j) Strings to remove - add whatever makes sense to you

2) Punctuation settings - I use all the defaults

3) Other path settings (e.g. node path settings) - these should be set based on how you want your urls to look like on your site. If you want all blog posts to start with "blogs" and include the user id and title, you could use:

blogs/[user-raw]/[title-raw]

If you create a special content type and what that to be part of the url, you can do that as well, e.g.

[type]/[title-raw]

Simply look at the "replacement patterns" and decide what pieces you want to use in your URLs for different content types. You can create your own replacement patterns using tokens.

It is good idea to try to think through your Drupal pathauto URL aliases settings before creating a bunch of content so you don't have to worry about the aliases changing due to changing your rules and patterns.

Comments

Updating pathauto URLs...

Hi,
I have a site that's not yet live yet, and I wanted to change my pathauto settings after already creating some content. Is it safe to use pathauto to delete all the aliases and then recreate them? For some reason the "Do nothing. Leave the old alias intact" option is not working - the aliases do not change. Thanks!

Pathauto

If you want the aliases to be updated, then you shouldn't use "Do nothing. Leave the old alias intact" because it will leave the alias to whatever was first created.

If you haven't gone live, you can temporarily set it to "create new alias, delete old alias" and then use the admin/content/node page to update all the aliases in bulk so they are all current.

Then switch the pathauto update setting to whatever is appropriate for your site (e.g. do nothing, or update and redirect).

Good luck,
Kristen

I'm new to Drupal and after 2

I'm new to Drupal and after 2 months of studying is finalising the very first site of mine.

I have had many questions along the way and , surprisingly enought, google very often give me your site with answers to those questions. Good work and thank you!

Replacement Patterns

Thanks for the great site! I'm new to Drupal and it is fairly daunting. But the articles on your site do a great job of consolidating what is important and simplifying it.

My question is: In the article Pathauto 5.x.1.x to 5.x.2.x New Features and Upgrade (I know it's 5.x rather than 6.x, but do these things still apply?) the mention using

For "Content Patterns"
[user] should be [author-name-raw]

but in the "Blog replacement patterns" in the admin section [author-name-raw] is not a given option. IT IS available in the "Node Path Settings" replacement patterns. Can one use that across the board in the other areas or is it variable (replacement pattern) that is not available in the blog?

Thanks

Tokens

Hi Stephen,

You are restricted to whatever replacement patterns (tokens) that are shown for the section you are editing, so you'll have to find the best match for whatever data you need. In this case, for the blog posts, you should have a [user-raw] available if you want the author's name. I'm not sure why it's not consistent between the two... definitely confusing.

Good luck!
Kristen

I'm a Speaker at DrupalCon Portland