Setting Up Search Friendly Links in Drupal with Pathauto

Drupal comes fairly bare boned, as everyone probably noticed. So barebones that the URLs are just plain indexes. Now, this would be okay for a web page not concerned with search engines, publicity, or ease of use—say an internal company web page where everyone is forced to use it anyway. However, in my case—and in probably every other public Drupal case—we need clean, easy to use links. Something like http://mydrupaladventures.com/content/my-experiences-migrating-wordpress-drupal instead of http://mydrupaladventures.com/content/2 which really tells nothing.

So, to do this the developer must enable certain things. Of course, the more you add, the slower the page—however do not be worried. I have added about 10 and counting modules on my web page and the site runs 100% fine (I'll talk about caching in another blog post soon). What we will be adding is a module called Pathauto and Token.

I will reference the fantastic guide over at The Site Wizard which I based most of my knowledge from. There are many counter intuitive things developers must get used to in Drupal. For one thing, one can't just use pathauto, they must first enable a module called Token. All token does is allow a developer (or module) to place text via place-holders, such as [user]. This is vital for pathauto's function because when pathauto creates the links, we clearly want the URL to automatically be the title.

Although The Site Wizard made an excellent article, I do want to make some points. I'll assume you followed the basic set up of putting the module in your /root/sites/all/modules/ directory and enabled it in site-configurations. Also you enabled Clean URLs in Administer->Site Configurations->Clean URLs. Okay? Good. J

  • Don't make your aliases at the root
    • That is, I chose to make my welcome page http://mydrupaladventures.com/welcome however, if I had other contributors to this blog, they could potentially high-jack important features in here if they created a blog entry
      • {root}/google12345676.html
    • The problem with that is those Google code links are important for importing site maps and if someone were to create an alias with it, it would throw everything off
      • Also applies to other search engines like Live and Yahoo
  • Don't make your alias "index.html"
    • I hope this is obvious to all, but clearly this will override what you really want. Bad!
  • Creating an alias that is the same as a user's name, a blog name, etc.

To avoid these problems, as an administrator, don't mess with the main settings of pathauto! It should automatically be set right. Make sure that all pathauto links go into subdirectories and only you, the main administrator can choose the specific link. That is, for all normal contributors, their titles are automatically generated.

Some other important points:

  • In the pathauto general settings I chose to keep all characters lower case. This keeps things simple, guarantees no case problems with search engines or if your host doesn't prefer them and most of all, no one really cares if a link is upper or lower case. Lower wins
  • As for maximum number of objects to alias at once…
    • The default is 50, but I rose to 100. Honestly, I think most good databases can handle a lot.
  • Update Action
    • This one has a few exceptions
    • For all normal use, keep it as "Do Nothing"
      • The reason I did this is because if I ever change the title of a post after it has already been indexed by Google, I don't want pathauto to also change the URL.
      • If I really want to change the URL, I will do it manually.
    • The exception to this rule is if I just imported or I am doing bulk conversion.
      • I ran into this issue when I bulk imported all my wordpress blog entries into Drupal
      • I originally had the "Do nothing" option enabled and I did not realize it. So, when I did the bulk generations, nothing happened! I shat a few bricks at that point…
    • So if you are doing bulk conversion and Google hasn't indexed your stuff yet, be sure to enable "Create a new alias. Delete the old alias."

I really want emphasize how great pathauto is. The bulk generations are invaluable. If you are wondering what I mean by bulk generations, just look at your "Blog Path Settings" or "Node Path Settings" dialog box. It will be in there. Again, when using the bulk generations, make sure "Do Nothing" is not selected or it will… do nothing.

Having that set up should do well for anyone. Of course, I didn't go into the most of knitty-gritty details, but as a developer, you really do need to poke around with every setting, research what things do and if it will support your site's goals. Hopefully this will save some of you at least 2 or 3 hours worth of research and time surfing the net. If there are any questions, leave a comment and you can have your comments tracked if you join up! (However, I do plan to make a blog post about how to take full advantage of Drupal.org's amazing support forum).

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Good Article

Very good article. I'm in the process of incorporating Pathauto at my site and currently testing on my test environment.

Another advantage is that by implementing Pathauto, it's possible to better manage your blocks, whether they appear or not. At my site in relation to the forum (still basic at the moment) I'm wanting to not have the Google Ads appear in the right-sidebar, but I want them there otherwise. I want the forum to look more like a forum. With Pathauto it's possible to enforce this via the blocks by entering settings to NOT appear on certain pages. Without Pathauto, this would be impossible.

Steve
Prime 357

Interesting..

Since I set up pathauto to handle all links, I didn't really consider more of its uses to create exceptions between blocks. If I every run into that, I will definitely ask you more about this. It doesn't seem too obvious how to do on first glance.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.