Skip to Content

Drupal Nofollow Link Sculpting

"Link sculpting" (also know as "pagerank sculpting" or "link juice flow optimization") is one of the more recent and popular trends in search engine optimization. Although some people have been using this concept for years, it has entered the SEO mainstream over the past year or so.

The idea is that if links are "votes", then you only want to vote for the content you care about on your website. So, if there are pages on your site that don't really add much value in terms of SEO yet you want to keep them for your users benefit, then you can use the "rel=nofollow" attribute on the links to that page or in the meta data in the page. This will notify the search engines that, for some reason, you don't want them bothering with that page, and don't want to give them any link juice. Examples might be a "policy" or "copyright" page, which would often be linked to on every page of your website yet isn't that SEO worthy.

Many sites use "nofollow" for any links within user-generated content (including drupal.org and wikipedia) since they cannot vouch for the link and it may end up pointing to a spam site. You don't want your site associated with bad sites, so this is a proper use of "nofollow". But, more recently, "nofollow" has been adopted into use for link sculpting as well.

There is some controversy over the use of "nofollow" for pagerank sculpting. One naysayer is well-known SEO expert Shari Thurow who discusses not using the "nofollow" attribute. But, the original idea was strengthen by Google's own Matt Cutts when he said:

"The nofollow attribute is just a mechanism that gives webmasters the ability to modify PageRank flow at link-level granularity. Plenty of other mechanisms would also work (e.g. a link through a page that is robot.txt'ed out), but nofollow on individual links is simpler for some folks to use. There's no stigma to using nofollow, even on your own internal links; for Google, nofollow'ed links are dropped out of our link graph; we don't even use such links for discovery. By the way, the nofollow meta tag does that same thing, but at a page level."

So while Shari believes that it's bad information and site architecture to need to rely on "nofollow", Matt is saying that it's not really a problem. So, many people are on the pagerank sculpting bandwagon including those doing Drupal SEO.

There are several ways to you can deal with using "nofollow" in Drupal to optimize your link juice flow:

  • Nofollow Module - Drupal 5 only and only dev version.
  • Meta Tags (nodewords) Module - You can set the nofollow on the page itself.
  • Menu Attributes Module - My new favorite module! Only available for Drupal 6, it was just developed in the last month or so. You can set all sorts of handy attributes for any menu item. Why didn't anyone do this feature before?!

So, get your link juice optimized using Drupal nofollow link sculpting techniques today... it's easy!

ALL COMMENTS ARE MODERATED AND SPAM WILL BE DELETED SO SAVE YOUR TIME AND MINE AND ONLY LEAVE A COMMENT IF YOU ARE REALLY LEAVING A COMMENT AND NOT TRYING TO LINK OFF TO ANOTHER SITE FOR SOME GOOGLE LOVE.

Comments

Nofollowing unimportant links

Is there a way to add nofollow to other unimportant links on drupal website, like log in, register, syndicate...?

Excellent Question!

This is an excellent question. Although I haven't done this, you can do a lot in drupal so I'm sure there is a way. This particular task, though, would probably have to be handled in code. You can theme menu links with your own theme function. I haven't tried the code, but I imagine it's something like:

function xxxxx_menu_item_link($link) {
  if ($link['href'] == 'something') {
    $link['localized_options']['attributes']['rel'] = 'nofollow';
  }
  return l($link['title'], $link['href'], $link['localized_options']);
}

Where xxxxx is the name of the theme you are using. This could be put in the template.php file for the theme. You will want to create your own theme rather than hacking a core one though.

New module

I'm creating a new SEO module to contribute to drupal.org so perhaps I will add in code there for this feature. It could have a configuration/settings page where you type in all the patterns that you want to do nofollow for. I imagine this would be useful for people.

That would be very useful. I

That would be very useful. I tried applying code from the comment before, but with no success. I tried modifying it a bit, but I'm not very good at php.

I got it to work for menu items

Try something like this for menu item links:

function phptemplate_menu_item_link($link) {
  if (! is_array($link['localized_options'])) {
    $link['localized_options'] = array();
  }
  if (! is_array($link['localized_options']['attributes'])) {
    $link['localized_options']['attributes'] = array();
  }
  if ($link['href'] == 'xxx') {
    $link['localized_options']['attributes']['rel'] = 'nofollow';
  }
  return l($link['title'], $link['href'], $link['localized_options']);
}

If you have your own theme, you can change phptemplate_ to yourthemename_. If you don't, you can leave it as phptemplate_ and put the function in one of your modules.

Oh, one thing is that you have to clear your cache after adding the function. Perhaps you didn't do that. The theme registry needs to be flushed to pick up your change. See my post on getting Drupal theme changes to show up.

Note that if the link is not in a menu then this code isn't going to help. If it's in a breadcrumb, you'll need a different theme function. If it's just output by a module directly using l(), then I'm not sure you can do anything.

I'm not trying to nofollow

I'm not trying to nofollow menu links. There is a great menu attributes module for that. I'm "fighting" with register new account, request new password and syndicate links. I found solution in Dan Druick's Drupal SEO post for register account and new password links:

Open the modules/user/user.module file in Notepad or some other text editor. Find the below:

$items[] = l(t('Create new account'), 'user/register', array('attributes' => array('title' => t('Create a new user account.'))));
}
$items[] = l(t('Request new password'), 'user/password', array('attributes' => array('title' => t('Request new password via e-mail.'))));

and change to:

$items[] = l(t('Create new account'), 'user/register', array('attributes' => array('title' => t('Create a new user account.'), 'rel' => t('nofollow'))));
}
$items[] = l(t('Request new password'), 'user/password', array('attributes' => array('title' => t('Request new password via e-mail.'), 'rel' => t('nofollow'))));

It worked at one of my sites, but on the other website the links didn't receive nofollow attribute. It is driving me crazy now. I cannot figure out why it is not working. It is not problem with caching. Any ideas?

Modifying Core

Well, modifying the core drupal code is not a good idea. Because when you need to update the core due to a security patch (which happens regularly), then you'll have to remember all the changes you made and do them all again and again.

My suggestions would be to:

1) use nofollow on the page itself so the links on that page are not followed

or

2) use the robots.txt file (or robotstxt module) to block search engines from those pages

or

3) use the .htaccess file to block search engines from those pages

I'm not sure why the change you made is working on one site but not another. You don't need the t() function in your case because you would never want "nofollow" translated into something else, so I would get rid of that, but that shouldn't change the behavior.

In the end, if the links are only showing up on one page on your site, then I wouldn't stress about getting 'nofollow' on them. If they are on ever page of the site, then it's more important. You can always replace the login block with your own that don't have those links, or just a "Login" link in your navigation that goes to the login page.

Post new comment - ALL COMMENTS ARE MODERATED - SPAM WILL BE DELETED!

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Powered by Drupal, an open source content management system