How To SEO Optimize Your Drupal Site

Drupal already has clean URLs and that is a big plus, you don’t need a special module for clean SEO friendly URLs. It needs a module for meta tags called node words but that can be easily added. But there are still some glitches that can be improved. The best way is to do it manually.

You know that SE don’t like duplicate content. And this is exactly what is happening inside Drupal site. With proper structure that is SEO friendly you can significantly increase the traffic to your site.

Drupal And Duplicate Content

For example your Drupal site can have 2 exact URLs, one points to a file and the other to directory.

http://mysite.net/articles/Drupal-SEO
http://mysite.net/articles/Drupal-SEO/

So on a normal Drupal site with clean URLs enabled Drupal will show the same content for both these links. This is useful because people can link to either one and not get a 404 error.

But regarding SEO, having 2 pages with same content might hurt you bad. This is known as duplicate content in SEO world.
Duplicate content can reduce your traffic. There is a simple solution for this Drupal SEO problem.

Redirecting Drupal with the .htaccess File

Every Drupal site has a .htaccess file that tell your server how to handle your sites URLs. So you need to just add 3 custom lines at the end of your .htaccess file so the server will automatically remove any trailing slashes in URLs.
#remove  trailing slashes

RewriteCond %{HTTP_HOST} ^(www.)?seoandwebdesign\.com$ [NC]
RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]

This is the code that works. The trailing trashes are removed from URLs. Instead of my site SEOandwebdesign.com use your URLs and also change the .com in the code if your site is .net or .org.

So the search engine bot will be redirected to the correct URL. This way you can protect your site against duplicate content.

Using robots.txt To Hide Duplicate Pages

We're not done yet, there's still some duplicate content to take care of. Here's our next example:

http://seoandwebdesign.com/articles/Drupal-SEO
http://seoandwebdesign.com/node/44

(I am using the URLs of my site seoandwebdesign.com that is actually a Joomla site not Drupal, so bare that in mind, replace my domain name with yours. )

Again here are 2 URLs with the same content but different URLs. Google does not know that and your site will trigger Google duplicate content trigger. So each page with friendly URL has also a default node URL that has to be excluded from Google index.
To do that you just simply add this line to your robots.txt file.

Disallow: /node/

Not all the search engine bots will ignore all the node URLs and that will eliminate duplicate content problem.
But if there are some pages that do not have custom set URLs, and have only node URL, those pages will not be indexed at all. SO be careful to set each page with friendly URL and insert some keywords in URL. You can use pathauto module to automatically generate URLs.

Drupal Global Redirect Module

You can also use this module Global Redirect module that will forward all of your /node/ URLs to the proper alias, and it even removes trailing slashes for you. If you have recently started to use SEO friendly aliased URLs instead of simple node ones, this module is your best choice.

But if you have used aliased URLs from the start this won’t be an issue for your site. I prefer setting robots.txt and .htaccess files manually, and reduce the module server load.

Nice tutorial here. Restricting duplicate content with .htaccess redirect is something not a lot of people are familiar with. I usually have to read up on htaccess every time I do it to refresh my memory.

Add new comment

The content of this field is kept private and will not be shown publicly.

Plain text

  • No HTML tags allowed.
  • Web page addresses and email addresses turn into links automatically.
  • Lines and paragraphs break automatically.