Drupal 7 module: Pathauto Configuration

In previous blog post I've introduced Pathauto Drupal module. Today I'm going to have a look how to configure it and how to achieve my goal having blog post URLs something like blog/2011/drupal-7-module-pathauto.

Path auto module is installed and enabled in my Drupal 7 installation. As mentioned in other blog post I had to have Token module installed prior as well. Configuration for Patrhauto for D7 is little bit different than Drupal 6 but basic idea is the same. So how to enable automatic URL for blog posts? In the main navigation for admin there is "tab" called Configuration. After clicking on it, there are multiple configuration options available. We are going to change URL aliases settings. When looking at URL aliases settings page there are multiple tabs on top right corner (List, Patterns, Settings, Bulk Update, Delete Aliases).

To configure Pathauto "Patterns Tab" is important.

So navigation to the setting page for Pathauto is as follows: Administration Menu => Configuration => URL Aliases (Search and metadata section) => Patterns Tab.

For our blog entry I need to configure Pattern for all Blog Entry paths in the CONTENT PATH section (first section in the list).
The configuration string for me is: blog/[node:created:custom:Y]/[node:title].

There is a lot of different replacement patterns available and it is just up to you to decide which one you want to use. Those patterns/tokens are more advanced than in Drupal 6. Five default categories are: Current Date, Current Page, Current User, Nodes, Site Information.

Following is list of some replacement patterns available by default at Drupal 7.

Current date - Tokens related to the current date and time.
Custom format [current-date:custom:?] - A date in a custom format. See the PHP doc for details.
Long format [current-date:long] - A date in 'long' format. (Tuesday, February 15, 2011 - 17:31)
Medium format [current-date:medium] - A date in 'medium' format. (Tue, 02/15/2011 - 17:31)
Raw timestamp [current-date:raw] - A date in UNIX timestamp format (1297816311)
Short format [current-date:short] - A date in 'short' format. (02/15/2011 - 17:31)
Time-since [current-date:since] - A date in 'time-since' format. (41 years 1 month)

Current page - Tokens related to the current page request.
Title [current-page:title] - The title of the current page.
URL [current-page:url] - The URL of the current page.
Internal path [current-page:url:path] - The internal Drupal path of the URL.

Current user - Tokens related to the currently logged in user.
Created [current-user:created] - The date the user account was created.
Custom format [current-user:created:custom:?] - A date in a custom format. See the PHP doc.
Last login [current-user:last-login] - The date the user last logged in to the site.
Custom format [current-user:last-login:custom:?] - A date in a custom format. See the PHP doc.
Name [current-user:name] - The login name of the user account.
User ID [current-user:uid] - The unique ID of the user account.

Nodes - Tokens related to individual content items, or "nodes".
Author [node:author] - The author of the node.
Created [node:author:created] - The date the user account was created.
Last login [node:author:last-login] - The date the user last logged in to the site.
User ID [node:author:uid] - The unique ID of the user account.
Content type [node:content-type] - The content type of the node.
Name [node:content-type:name] - The name of the content type.
Date created [node:created] - The date the node was posted.
Custom format [node:created:custom:?] - A date in a custom format. See the PHP documentation.
Long format [node:created:long] - A date in 'long' format. (Tuesday, February 15, 2011 - 17:31)
Medium format [node:created:medium] - A date in 'medium' format. (Tue, 02/15/2011 - 17:31)
Menu link [node:menu-link] - The menu link for this node.
Name [node:menu-link:menu:name] - The name of the menu.
Parent [node:menu-link:parent] - The menu link's parent.
Menu [node:menu-link:parent:menu] - The menu of the menu link.
Root [node:menu-link:parent:parent:root] - The menu link's root.
Internal path [node:menu-link:parent:url:path] - The internal Drupal path of the URL.
Title [node:title] - The title of the node.
User ID [node:source:author:uid] - The unique ID of the user account.
URL [node:url] - The URL of the node.
Absolute URL [node:url:absolute] - The absolute URL.
Alias [node:url:alias] - The alias of the URL.

Site information - Tokens for site-wide settings and other global information.
Email [site:mail] - The administrative email address for the site.
Login page [site:login-url] - The URL of the site's login page.
Name [site:name] - The name of the site.
Slogan [site:slogan] - The slogan of the site.
URL [site:url] - The URL of the site's front page.
URL (brief) [site:url-brief] - The URL of the site's front page without the protocol.

I believe that node related patterns are most used. Here are some other examples:
Blog post categorized by year and month:
blog/[node:created:custom:Y]/[node:created:custom:m]/[node:title]
Example: blog/2011/03/drupal-7-module-pathauto-configuration

Blog post categorized by author and year:
blog/[node:author:name]/[node:created:custom:Y]/[node:title]
Example: blog/marek/2011/drupal-7-module-pathauto-configuration

So many options available. It is just up to you which one you want to use. Drupal is giving you tools you just have to properly use them.

Vocabulary:
D6 - Drupal 6
D7 - Drupal 7 available since 2011.

Blog Image: