If you are running a drupal 7 (and perhaps other versions) site, and your site has a bunch of users, you may want to listen up.

You have probably noticed that your User profile URL’s always point to the UID number (user id), which isn’t particularly user friendly.

So pathing currently looks something like this:

www.mycooldrupasite.com/user/257

And this actually goes to John Hancock’s profile page… But you would never know that based on the URL. This is fine, if your site/web application really isn’t dependent on users being able to easily find other user’s profile pages. However, if you DO need to let your users easily find other users profiles, one of the things you should look into is URL Aliasing the profile page URL. URL Aliasing… what’s that you ask?

Aliasing simply means giving the same page or node on your site an alternate URL path (often a more user friendly one than what drupal auto-generates). So in this brief write-up I am going to talk about how to change John Hancock’s profile page from:

www.mycooldrupasite.com/user/257

to

www.mycooldrupasite.com/users/jhancock

–or– if you prefer

www.mycooldrupasite.com/users/john-hancock

Let’s dive in…

This requires a couple of modules…

If you are Drupal 6, you need to get the tokens module and install it. This is a part of Drupal 7 core so you can skip this step if you are running Drupal 7. In my last post about using View’s Megarows I discussed the concept and use of “tokens” in Drupal 7 at length. Feel free to give it a read.

Next, regardless of what version you are running, you need to get and install the Path-Auto module.

Finally, I also recommend the “real name” module. However this is optional. That being said, I am not sure how this module behaves in Drupal 6 as the authors did a major re-write for Drupal 7.

Okay, now that all of that is installed, lets configure your user profile paths using the Path-Auto module (this was taken almost directly from this post)

  1. As an Admin, go to Configuration. Under ‘SEARCH AND METADATA’ select ‘URL aliases’.
  2. Select the ‘Patterns’ tab and scroll down to ‘USER PATHS.
  3. In the box put: users/[user:name] and then save configuration.
  4. In the same window, at the top, go to the ‘Bulk update’ tab.
  5. Put a check mark next to “User Paths” and click Update.

Step 3 is the vital step. If you are using the Real-Name module to convert usernames (jhancock) to full names (John Hancock), then your pathing using the [user:name] token is going to look like this:

www.mycooldrupasite.com/users/john-hancock

You may prefer to use the user’s login name for the URL path because it is shorter. In my case, the application I am working on is accessed by a lot of Indian and US users… the Indian names can get to be very long and they are hard for Western users to spell out in a url. The user login name is therefore preferable for pathing. So if your goal is to make the profile URL looks like this:

www.mycooldrupasite.com/users/jhancock

And you are using the RealName module… then in that case you would use a different replacement token, provided by the RealName module:

users/[user:name-raw]

“name-raw” means use the user’s login username, not their full name.

Couple of other notes:

-If you accidentally “bulk update” once and don’t like your results. You can also bulk-delete from the “Delete” tab. Selecting just “user profiles” aliases to delete.

-Bulk-Updating will only create new aliases… it will not overwrite existing ones with new information. Hence if you use one token and bulk-update, and then decide you want to use different token instead, you must delete the current aliases first.

1 of 1

One comment on: Drupal – PathAuto – Making User Friendly Profile URLs

  1. dapo
    Reply

    Concise tutorial. Learn a lot. Thanks for putting this together.

Join the discussion

Your email address will not be published. Required fields are marked *