Drupal Design Tip: Clean URL Design

Submitted by Jesse Mutzebaugh on 04/25/2013 - 09:22:am

With good site structure and hierarchy planning you can use URL's to your advantage.

Eliminate Breadcrumbs

Take a look at the following two URL's:

http://www.example.com/gp/product/B0002K11BK/ref=sr_1_5?ie=UTF8&qid=134…;

http://example.com/furniture/office/herman-millers-mirra-chair

By looking at the bottom url, I can easily see where I am in the site's heirarchy, what the product is categorized as, and where to go if I want to view other products.

With this model, you can effectively eliminate the need for a "breadcrumbs" section of your webpage and save yourself 50 pixels of real-estate on your pages.

Content becomes more "sharable"

If you are primarily delivering content, you need good URL's. Imagine seeing the following tweets:

Check out this article: example.com/p=rfp_6295
Check out this article: examp.le/j3sU5

Check out this article: example.com/sales-conversion-tips

Complex URL's - and even short urls from bit.ly - only make sense in context of converstaion (if someone sends a link in a chat conversation). But if a user sees a link that is out of context, they are far less likely to investigate it.

Bonus - when using URL-shrinking services like bit.ly, please use custom shortnames. Understand that bit.ly/Starbucks is way better than bit.ly/cH21s7

Exceptions

Not all complex URL's are bad. It really depends on your specific use case

Tracking

For example the following links produce the same search results:

https://www.google.com/search?q=good+url+design&aq=f&oq=good+url+design…

https://www.google.com/search?q=good+url+design

So why doesn't Google use clean URL? In short, all that complex information is used for mining data. Google can track where I'm from, what browser I'm using, track query history, etc... in order to produce better search results for me. You'll notice Amazon does this as well in order to produce better search results for you based on your browsing history.

Security

Normally, logged in session information is stored in a cookie - a file that gets stored on your system. But what if you need to send someone a link that requires special permissions to a user that does not have a cookie on their computer?

If you've ever forgotten a password, a good CMS will send you a lengthy generated URL that looks like pure chaos. That's to protect you. Imagine seeing this in your inbox:

To reset your password, just visit: example.com/your_user_name/reset-password

That poses a great security risk as anyone can type that in their browser to reset your password. Because of the complexity of the generated link, the chances of someone "stubling" upon your reset URL is near zero.

Another possible example of this, suppose we have a wiki page somewhere which we let only administrators edit various web pages. We need a flag in the URL that indicates the reader is an admin, so let’s call it “a=1″. Then, everyone else will need to know if the page is:

  • readable p=r
  • writable p=w
  • both p=rw

So, a typical URL might look like: http://www.example.com/wiki/SomeImportantPage?a=1&p=rw. For folks who aren’t administrators, the wiki might render the same link to the same page as: http://www.example.com/wiki/SomeImportantPage?p=r. Note that, in this case, non-admins get read-only access.

So I'd recommend you take time to evaluate the goals of your business and what is going to benefit your users the most. Once you determine what is of greater value, then you can speak to your developers about your options of how your URLs can be displayed.