How to Clean and Optimize URLs in Drupal

Just like websites of yore, Drupal uses a query string to pull information from a database. Every single blog post, comment, content, user entry, and so on is stored in tables on the server so you need a query string to go find the data and bring it back to the browser window. This is a fancy way of saying “URL”.

The standard Drupal URL comes in “dynamic” form. This means that there are strange characters in the URL that aren’t exactly kosher for SEO. Now, I don't strange characters via Jar-Jar Binks, but strange written characters that usually require the shift key to type. Here are some examples of standard, dynamic Drupal URLs:

• http://www.yourDrupalsite.com/?q=node/1

• http://www.yourDrupalsite.com/?q=taxonomy/term/2+4+7+21+24

• http://wwww.yourDrupalsite.com/?q=user/login

By no means have these URLs been “cleaned up” properly. Clean URLs are URLs that do not contain any strange characters like ?, =, &, (,), or $. In Drupal a clean URL look like this: http://www.yourDrupalsite.com/node/1.

Clean vs. Optimized URLs

Don’t confuse clean URLs with properly optimized ones, though. While a clean URL can be easily read, it doesn’t necessarily tell the search engines what your web page or web site is all about. Search Engine Optimized URLs contain keywords that you are targeting for in search.

An example would be: http://www.yourDrupalsite.com/austin-real-estate.

This URL indicates what content it is pointed at, and contains the keyword phrase: austin real estate. But before you can go optimizing the dickens out of your site, let’s turn on clean URLs in Drupal.

How to Turn on Clean URLs in Drupal

During installation, Drupal 6 will automatically run the clean URL test and will show you the results. If you weren’t the one to install Drupal or you don’t remember whether it worked or not, you should double-check to make sure that clean URLs are turned on.

1: Go to http://www.yourDrupalsite.com/admin/settings/clean-urls or visit your admin screen and click Clean URLs.

2: The Enabled radio button should be selected. If it is not, select it and click Save configuration.

If you cannot enable clean URLs

There is a remote possibility that your hosting company has some settings they need to adjust for you. Or you may need to edit your .htaccess file to make it work.

For common configuration issues, visit http://drupal.org/node/15365

How to Optimize URLs with the Path Module

Now that your site is pumping out clean URLs, you will need to start optimizing them. Clean URLs are not enough, no sir. Sure, search engines can read the URL much easier, but that is just the first step in making your website addresses work for better rankings.

Just like they look at Page Titles and body content, search engine spiders also comb through URLs for keywords. If you use keywords in your URL path, you will do much better than a site without them. Naturally, Drupal has a solution. The Path module allows you to write your own paths.

Drupal’s Path Module

A path is the part of the URL that comes after the top level domain – i.e. com, org, edu, biz, or info.

For example: in the URL: http://www.yourDrupalsite.com/pez-dispensers/boba-fett the path is /pez-dispensers/boba-fett.

The Path module allows you to manually create search engine friendly URLs based on your content. This allows you to get addresses that look like the following URLs:

• http://www.yourDrupalsite.com/football/best-college-rivalries.html

instead of:

• http://www.yourDrupalsite.com/?node=node/8217

The Path module was originally written and maintained by the great Matt Westgate, who has contributed early and often to Drupal’s success. Since Drupal 4.3, the Path module has been included in the Drupal core.

How to turn on the Path Module

Although the Path module is part of the core of Drupal 4.3 and later, it is not turned on by default. You must do it yourself. Here is a step-by-step guide:

1. Visit the link, http://www.yourDrupalsite.com/admin/build/modules or go to the admin screen and click on Modules.

2. Find the Core - optional section and then find Path. Add a check in the box.

3. Click on Save Configuration.

4. Visit http://www.yourDrupalsite.com/admin/user/permissions or go to Admin | User Management | Permissions and give permissions to users that need to create custom paths.

How to change a content path

Now you should be ready to change a content path on your Drupal site. Follow these easy directions and you are good to go:

1. Point your browser at the node for which you want to create a custom path.

• To create new content, visit http://www.yourDrupalsite.com/node/add

• To edit existing content, browse to the node and click on the Edit tab

2. In the URL path settings field, put the path that you wish to show in the URL. Only put the text that shows up after the / that comes after the base URL. If you want your alias to be http://www.yourDrupalsite.com/about then you would put about in the field.

3. Click on the Save button.

Writing Optimized URLs

To write your own optimized URLs, simply insert your keywords for the website into the path. For example, if your website targets gaming computers, put it in the path separated by dashes:

• http://www.yourDrupalsite.com/gaming-computers

While at first it may seem intimidating, it is fairly simple once you get the hang of it. Once the search engine spiders have had a chance to reindex your website, you should start seeing some of your newly optimized URLs pop up a little higher in the search rankings.


Cleaning and optimizing your URLs is just one of many steps in the process of Drupal SEO. Please join me each Friday on our blog as I discuss Drupal SEO tips, news, and know-how for you and your Drupal website team.

Thank You For Reading!

No one likes people who don’t share, especially giant flying cats. So if you liked what you read, please share my post with any of our socially-labeled buttons, or we’ll sick Fluffy after you! Please subscribe to our RSS feed as well so you can receive daily fodder from our blog.

Comments

Comment viewing options

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

Not So Quick,Not Like WP

No matter what i read on drupal, i still cant move away from wordpress. I like the method here as canonical URLs are so crucial, domains and all URLs on that domain should be keyword targeted. This is automatic in WP, why is this the way to do it in drupal?

The answer is Yes!

Thanks for the comment. While I agree that WordPress has some solid URL optimization plugins, Drupal has more! There are a variety of URL-oriented modules for optimization, including the ever-versatile Pathauto Module (the Drupal equivalent of Permalinks, except it does way more).

I like WordPress, but Drupal is much better for SEO.

Clean URLs

what is the best way of using space? I have been trying to clean my URls and make them tie in with my keywords but do I use a - for a space between each keyword? or a _?

Utilizing space in URLs

Adam,
That's a great question and one that is asked quite frequently. Yes, use a dash between each word in a URL. The search engine crawlers see a dash or an underscore as a normal space.

Also, remember these two elements:
-Keep your URLs to 70-80 characters (74 or less, ideally)
-Limit URLs to 3-4 keywords to avoid confusing the crawlers

What CMS do you have for your site?

Thanks,
Mitch

Clean URL

This is excellent information with enough detail on clean URL's. Thank you for your post and insights.

Clean URL Plays an important

Clean URL Plays an important Role from SEO Point of View. Drupal is one of the best CMS I have come across with. All this tips are definitely going to help me gain some benefit from SERP.

Execellent

Very useful and simple.
Thanks a lot.

Question/suggestion here

Hi ben,

I am a intermediate drupal developer. Currently developing my own project related to font-face font sharing website on drupal.

After reading your article, I would like to ask one question related to the keywords on urls. Sorry, if this question has not to do with the article you have written here.

On my site there are two taxonomies Vocabularies.

1) Font Style
1.1) Sans Serif
1.2) Poster

2) Font Foundary
2.1) Paragraph
2.2) Arrotype

According to these two vocabularies, what could be the best pathauto path for taxonomy urls as far as the search engine optimization is concern.?

http://www.yoursite.com/browse/font-style/sans-serif
http://www.yoursite.com/browse/font-style/poster

or

http://www.yoursite.com/browse-font-style/sans-serif
http://www.yoursite.com/browse-font-style/poster

or

http://www.yoursite.com/category/font-style/sans-serif
http://www.yoursite.com/category/font-style/poster

or

http://www.yoursite.com/font-style/sans-serif
http://www.yoursite.com/font-style/poster

Your inputs on these would be greatly appreciated.

Best Regards,
- Tejas Suthar

Hi

Tejas,
Apologies for the delay on responding to your message! Below are my thoughts on the issue...

I like the last option best. It cuts out an unneeded layer (/category/ and /browse/) in your URL's structure and gets right to the point with ample organization.

Definitely go with this one:
http://www.yoursite.com/font-style/sans-serif
http://www.yoursite.com/font-style/poster

The Volacci SEO Podcast

Ben Finklea talks with Stephen and Thomas from Tree House Agency and Robert Douglass of Acquia at Drupalcon 2009 in Washington DC.

Partner With Volacci

Being a partner with Volacci has many advantages

By participating in our referral program, you will financially benefit from any referrals you send our way.

The Volacci SEO Blog

Once you have conducted a content inventory/audit, and performed a content gap analysis, you...

SFCookie.include();
var jcexpire="30";
var jURLData = "" + window.location.search.substring(1);
if((jURLData && jURLData != null && jURLData != "null" && jURLData.length > 0) && jURLData.indexOf("jsid=") > -1)
ImageJSLandingProcess();