PathAuto Module for Drupal Improves SEO

The PathAuto Module for Drupal let’s you replace “unfriendly” URLs with “friendly” ones to make your site more appealing , both to users and search engines.  It works by taking the internal URLs Drupal uses to link to content, and creates aliases that are “friendly” based on your PathAuto settings.

Configuration Settings

To assign some basic parameters, use the following navigation to get to the PathAuto settings page:

Administer > Site building > URL alias > Automated alias settings

Basic settings
While the defaults are mostly fine, it’s better to select the option:

Do nothing. Leave the old alias intact.

This is found under Update Actions, and it will prevent your URLs from changing if you decide to change the title of an already-published node.

Punctuation settings
The only setting that you need to change in the Punctuation Settings section is the “hyphen” setting– change it to No action (do not replace).

PathAuto Rules

In this step, we assign power to the module. Each content type in Drupal can have a different set of PathAuto URL rules, and the URL rules are based on tokens like node ID number, node title, and author name.

Tokens
Tokens are small bits of text that act as placeholders for token values. These tokens can be placed into larger documents and other content via simple placeholders, like %site-name or [author-name]. The Token Module provides a central API for other modules to use these tokens.

Example:

The post [title] was written by [author-name].

would become:

The post PathAuto Module was written by H Hinkle.

Here are some tokens that apply to the node content type:

  • [nid] Node ID
  • [type] Node type
  • [type-name] Node type (user-friendly version)
  • [language] Node language
  • [title] Node title
  • [title-raw] Unfiltered node title. WARNING – raw user input
  • [author-uid] Node author’s user ID
  • [author-name] Node author’s user name

You can view the available tokens by clicking on Replacement Patterns in the PathAuto configuration page:

The other token groups are Taxonomy and Users. You can use the above-mentioned tokens as patterns in your PathAuto rules for each content type. These tokens act as replacement patterns. Here is an example of some URL rules:

Example:

Let’s say you have the following pattern for nodes:

[term-raw]/[title-raw]

A page called help under a vocabulary about, the URL will display:

about/help

Likewise, if you use the following pattern:

[term-raw]/[title-raw]-[nid].html

you will get:

about/help-31.html

PathAuto Rules Tip

If you’re using categories and vocabulary, apply the “Taxonomy”. For content types, use the “Node Settings”. You can completely customize your paths to your liking.

Remember: After customizing your PathAuto settings, you’ll need to regenerate aliases.

PathAuto Warnings

There is a page on Drupal.org regarding dangerous PathAuto patterns. You can avoid these dangerous patterns just by making sure you don’t use [title-raw] as the only setting for PathAuto — there should always be more information in the URL than just the title.

In other words, you don’t want someone to be able to create a node called “New post” and have the resulting URL be mysite.com/new-post.

If you want short aliases, at the very least make your pattern something like:

[nid]-[title-raw]

to prefix the node ID. Now, the URL will at least be:

123-new-post

Another recommendation is to start with static text that isn’t a reserved Drupal path/callback/directory.

Example:

“c/[title-raw]” to put a character “c” before every title. This URL will look like:

c/new_post

Here is an example of a longer URL:

[term-raw]/c/[title-raw]-[nid]

Download and Installation Details

You can download the PathAuto Module for Drupal here.

First, download the file, unzip it, and copy the unzipped folder to the Drupal module folder. You’ll also need to download and install the Token Module as PathAuto depends on tokens.

You can download the Token Module for Drupal here. Follow the same instructions as above.

Now, activate the downloaded modules. Log into your admin area and enable the modules using the following navigation: Administer > Site Building > Modules

First, check that the core path module is enabled and then enable the tokens, as shown below:

Next, enable the PathAuto Module:

Note: It is also recommended you install the Global Redirect Module, as this helps prevent duplicate aliases.

No Comments

Add a Comment

Please keep your comments relevant to this blog entry. Email addresses are never displayed, but they are required to confirm your comments.