Skip to main content

Proper URL aliasing

When clean URLs are enabled, Drupal automatically saves new content as /node/xxx with "xxx" being a serial number. Keeping this default URL scheme is less than desirable for two reasons:

  • It makes statistics hard to read.
  • It omits the chance of slipping search engines a few extra keywords.

Users having the "create URL alias" permission may set an alternative path for a node on the node's edit form. However, manually aliasing content is not really a convenient thing to do. Ideally, nodes should be aliased automatically, when saved and this is exactly what the pathauto module does (it also needs the token module to be installed. Bloggers, not blogging in in English may want to install the transliteration module as well).

Pathauto is a highly configurable module, offering a large number of settings under admin/build/path/pathauto. Fortunately, most of them come with sane defaults and do not need to be changed in most cases. What needs to be changed however, are the settings under "node path settings". Each content type, available on the system may be configured with an individual pattern for how to automatically alias nodes, when saving them.

Coming up with a good pattern for automatically aliasing content is more art than science. Some points to take into consideration:

All automatic aliases should reside in the same "subdirectory"
A very convenient pattern to use for example to alias all content types is content/[title-raw]. Putting all aliased content in the same "directory" ensures that there will be no nameclashes with system paths.
Make sure, aliases are as short as possible
Search engines present URLs to their users. Short and meaningful is advantageous here.
Do not try to feed information back into the system via aliased URLs
Something, a lot of people try to do, is to use URLs as a basis for toggling block visibility (e.g. making a block only visible for a specific content type by encoding the type in the URL and having the block trigger on that). This is notoriously unreliable, since naming schemes may change over time and there is always a chance of visitors accessing content directly via a leaked/guessed, unaliased URL. If URL feedback is required anyway, consider using the global redirect module as a work around.
Do not try to add structure to aliased URLs
Something, that can often be seen in blogs are URLs like content/[yy]/[mm]/[dd]/[title-raw]. Encoding the date in the URL is not needed in Drupal. Nodes do not exist as files in directories, so there is no need to worry about directories "flowing over".
It is also a disadvantage SEO wise to structure URLs like this. Short and meaningful URLs look much more appealing. Telling potential visitors the age of a post before they even visit the blog, may cause them to not visit at all.

Trying to structure aliased nodes also has the disadvantage of pushing keywords to the right. Relevant keywords should always appear as far left as possible in an URL.

Do not try to keep URL aliases in sync
One thing, that happens occasionally is, that the data, from which an URL was generated automatically changes. Do not try to keep an automatic URL in sync with that datasource. It is simply not worth the hassle.