Improving Drupal’s Clean URLs with the Pathauto Module

Enable Drupal Pathauto

This tutorial was requested by a student who is learning the Drupal basics. They turned on “Clean URLs” in the Drupal admin area and were surprised to see that the URLs remained largely unchanged:

  • Old: /?q=node/3
  • New: /node/3

The student’s comment was:

“that’s still a silly address for my About Us page. I want the address to be /about-us/.”

We also tried to help them by turning on the Path module in the Drupal core. That allowed them to create URLs like /about-us/ however they still needed to think about it and ask their users to create a path every time. They wanted something that would create great URLs automatically.

The solution is the “Pathauto” module and let’s show you how to set it up:

Installing Pathauto to Your Drupal Site

In fact, we’re going to install two modules because Pathauto also requires the “Token” module.

  • Step 1: Go to Administer >> Site configuration >> Clean URLs to check that they are enabled.
  • Step 2: Click here to download the latest version of “Pathauto” and click here for “Token”.
  • Step 3: Extract the files into a two folders on your desktop. One  folder will be called “pathauto” and the other “token”.
  • Step 4: Login to your site’s files via FTP and navigate to /sites/all/. If there isn’t a folder called /modules/ here, create one.
  • Step 5: Upload the “sections” folder to /sites/all/modules/
  • Step 6: Go to Administer >> Site building >> Modules. You’ll need to check four boxes:

    Enable Drupal Pathauto

  • Step 7: Go and create a new node. When you do, you should notice a new area labelled “URL path settings”. If you leave “Automatic alias” checked, the address of the page will likely be your Page title in this format:
    /content/your-page-title/

    Enable Drupal Pathauto

Configuring Pathauto

The default Pathauto setting might not be to everyone’s taste:

  • You may want to use underscores _ instead of dashes as this student did.
  • You may want to remove /content/ so that you really can have pages with the address /about-us/ rather than /content/about-us/

To change the settings, go to Administer >> Site building >> URL aliases >> Automated Alias Settings:

Drupal Pathauto Settings

{loadposition drupalnewsletter}

Author

  • Robbie Adair

    Robbie started her career in corporate training until starting her own custom training and media company almost seventeen years ago. In 2010, she began doing classroom training for OSTraining while running Media A-Team. She is often presenting about various tech topics such as Joomla, Fabrik, Web Development, Social Media, and Augmented Reality. She loves seeing that "ah-ha" moment in peoples eyes in her sessions and workshops. She lives in Houston, Texas, but enjoys all the travel for client work and speaking gigs.

0 0 votes
Article Rating
Subscribe
Notify of
3 Comments
Oldest
Newest
Inline Feedbacks
View all comments
bkube
10 years ago

Thank you. This was making me crazy

bakri
bakri
10 years ago

Very helpfull

Anisur
Anisur
6 years ago

Hi,

i have pathauto + url rewriting enabled on my drupal website.

My nodes are properly rewrited but google also displays nodes with node id in it.

For example these 2 links will be available for a car node:

[url=http://www.mysite.com/car]www.mysite.com/car[/url]

[url=http://www.mysite.com/node/56]www.mysite.com/node/56[/url]
Is there a way to mask the second url so that search engines and visitors can’t see or use it?

3
0
Would love your thoughts, please comment.x
()
x