Quantcast
Channel: Joonas Kiminki's blog
Viewing all articles
Browse latest Browse all 7

Drupal path mechanisms howto

$
0
0

Summary: Always always use the modules mentioned in this post to create an end user and search engine friendly path and redirect system in Drupal. Include this module set in your install profile or site setup workflow, which ever you use. If you’re not a believer after reading this post, please do comment your thoughts.

Background

URL paths on a website are important for many reasons. The paths serve the human reader by offering information on what the web page is about. They also provide search engines information about the content in question. This post is fundamentally not a SEO (search engine optimization) guide although performing the tasks in this walkthrough definitely have a positive SEO impact as well. The simple principles demonstrated here should be applied to all sites, even the ones with no SEO goal, such as intranets.

An out-of-the box Drupal does no cool tricks with URL addresses (called aliases within Drupal). All the content is displayed on very machine-like URLs, such as mysite.com/node/123. To make addresses human-friendlier, there is an optional core module called Path. With that you can create aliases for the built-in addresses. Your mysite.com/node/123 can then become mysite.com/blog-posts/my-day-at-the-zoo. Much better, eh?

- Yeah, but gimme automation.


Ok. The first companion for the Path-module is a tool to automatically create the aliases from your content type, menu, and/or post title (among dozens of other options). The functionality is provided by a module called Pathauto. After installing and configuring the module, your content can be automatically given a human-friendly URL alias. This is all fun and stuff, but not enough yet. What if you rename your post or do something else that would change the post URL? What if Google finds your content in multiple addresses (since all the aliases are actually aliases, not replacements for your original content)? Time to introduce two principles:

  1. No content shall ever have multiple addresses. This reason is mainly SEO-based but can also help avoid human confusion and improve usage analysis (analysis software typically analyze by URL). There are many cases when multiple URL's or short links are needed, but the way to do it is redirecting to the primary address.
  2. No URL shall ever stop working. If you change the address of your content (which could very well be justified), the old addresses must remain functional. Considering rule number one, you need to do a redirect.


Time to bring two new players to the game: Global Redirect and Path redirect. The first mentioned will remove the issue of having multiple addresses for your content by redirecting all requests for a piece of content to a single path. The second mentioned module, Path redirect, will (when configured) delete old aliases when new ones are created and add a redirect from the old path to the new one. Global Redirect and Path redirect can even do a couple more handy tricks, such as “garbage collection” deleting of unused old redirects. Read more on the modules’ project pages.

- Shut up and show me the money!


Ok, the explaining part is over, let’s go and do it. This is super-simple.

  1. Download and install all the above mentioned modules plus Token, which is required by Pathauto. Links here:
    http://drupal.org/project/pathauto
    http://drupal.org/project/token
    http://drupal.org/project/globalredirect
    http://drupal.org/project/path_redirect
  2. Enable the modules, clickety click.
  3. Configure Pathauto to “Create a new alias. Redirect from old alias.”

Pathauto setting "Create a new alias. Redirect from old alias."

 

That's it, you’re done!

There is a lot more to do especially with Pathauto configuration, but that is optional and site-specific and will not be covered here and now.

Drupal 7 remark: All the modules either have an existing D7 version or the #D7CX pledge to release a stable version by the day D7 is out.


Viewing all articles
Browse latest Browse all 7

Trending Articles