As anyone paying a close attention to their Page Rank and SEO will already know this, too many outbound links from your webpage can drain the "Link Juice" of your webpage andcan hamper the Page Rank and SEO value of your website. This is especially true when you are displaying hundreds of comments on the same page and each comment links to the user homepage (which may be offtopic).
Since I am not an expert in this area, the focus of this post is not to explain or debate about Page Rank, Link Juice, SEO or PageRank sculpting.. If you are worried about "Link Juice" of your node pages getting drained by the above scenario, here is how we can use rel=nofollow method on comments.
Drupal 6 makes this task rather easy by providing very useful hook_preprocess functions..
If (like me) you are using the Gravatar module, insert the following (patched) function to your template.php file (inside your theme folder).
<?php
function mytheme_preprocess_user_picture(&$variables) {
$variables['picture'] = '';
if (variable_get('user_pictures', 0)) {
$account = $variables['account'];
$picture = NULL;
// If this is a node or comment object, load the user object.
if (!empty($account->nid) || !empty($account->cid) || empty($account->roles)) {
// If a comment is being edited and previewed, the $account->uid is NULL.
// @todo Remove when <a href="http://drupal.org/node/334826" title="http://drupal.org/node/334826">http://drupal.org/node/334826</a> is fixed in 6.x.
if (!isset($account->uid)) {
$account->uid = 0;
}
$account = user_load($account->uid);
// Load mail/homepage variable from an anonymous comment.
if (empty($account->mail) && !empty($variables['account']->mail)) {
$account->mail = $variables['account']->mail;
}
if (empty($account->homepage) && !empty($variables['account']->homepage)) {
$account->homepage = $variables['account']->homepage;
}
}
// Load alternate Gravatar e-mail address.
// @todo Remove this.
//if (!empty($account->gravatar_mail)) {
// $account->mail = $account->gravatar_mail;
//}
// Decide with picture to use.
if (!empty($account->picture) && file_exists($account->picture)) {
// If the user has an uploaded picture, use it first.
$picture = file_create_url($account->picture);
}
elseif (!user_access('use gravatar', $account) || (user_access('disable own gravatar', $account) && isset($account->gravatar) && !$account->gravatar)) {
// If the user does not have access to use gravatars or has gravatars
// disabled for their account, use the global default image.
$picture = _gravatar_get_default_image(GRAVATAR_DEFAULT_GLOBAL);
}
else {
// Otherwise, show a gravatar with the appropraite default picture.
$picture = _gravatar_get_gravatar(array('mail' => $account->mail));
}
if ($picture) {
$alt = t("@user's picture", array('@user' => $account->name ? $account->name : variable_get('anonymous', t('Anonymous'))));
$variables['picture'] = theme('image', $picture, $alt, $alt, NULL, FALSE);
if ($account->uid && user_access('access user profiles')) {
// Create link to the user's profile.
$attributes = array('attributes' => array('title' => t('View user profile.'), 'rel'=>'nofollow'), 'html' => TRUE);
$variables['picture'] = l($variables['picture'], "user/$account->uid", $attributes);
}
elseif (!empty($account->homepage)) {
// If user is anonymous, create link to the commenter's homepage.
$attributes = array('attributes' => array('title' => t('View user website.'), 'rel'=>'nofollow'), 'html' => TRUE);
$variables['picture'] = l($variables['picture'], $account->homepage, $attributes);
}
}
}
}
?>
If you are using the vanilla install of drupal, you can use this:
<?php
function mytheme_preprocess_user_picture(&$variables) {
$variables['picture'] = '';
if (variable_get('user_pictures', 0)) {
$account = $variables['account'];
if (!empty($account->picture) && file_exists($account->picture)) {
$picture = file_create_url($account->picture);
}
else if (variable_get('user_picture_default', '')) {
$picture = variable_get('user_picture_default', '');
}
if (isset($picture)) {
$alt = t("@user's picture", array('@user' => $account->name ? $account->name : variable_get('anonymous', t('Anonymous'))));
$variables['picture'] = theme('image', $picture, $alt, $alt, '', FALSE);
if (!empty($account->uid) && user_access('access user profiles')) {
$attributes = array('attributes' => array('title' => t('View user profile.'), 'rel'=>'nofollow'), 'html' => TRUE);
$variables['picture'] = l($variables['picture'], "user/$account->uid", $attributes);
}
}
}
}
?>
As you will notice, in both the above patches, I have just edited the line below
<?php
$attributes = array('attributes' => array('title' => t('View user website.'), 'rel'=>'nofollow'), 'html' => TRUE);
?>
It doesnt get easier than this!!

















4 comments
27th Jun, 09
I think adding the rel='nofollow' to the anonymous user's homepage links is very worthwhile. But beware. Two out of the three changes above are adding rel='nofollow' to internal user profile page links (user/x). I wouldn't think you'd want to add nofollow to links to other pages in your own website.
Therefore, the only change that seems valid is
<?phpelseif (!empty($account->homepage)) {
// If user is anonymous, create link to the commenter's homepage.
$attributes = array('attributes' => array('title' => t('View user website.'), 'rel'=>'nofollow'), 'html' => TRUE);
$variables['picture'] = l($variables['picture'], $account->homepage, $attributes);
}
?>
Also, we should probably use rel='external' in addition to nofollow.
13th Jul, 09
Google has changed the way it handles links with rel=nofollow, the changes mean the only way to boost linkjuice is to reduce the no of links on your page - regardless of whether nofollow has been set.
See http://www.mattcutts.com/blog/pagerank-sculpting/
8th Dec, 09
How good and how speicialized it is is another thing. Years ago i made a company website with wordpress. No blogging section at all. Well that was before i knew Drupal, but i did work very well. The customer could manage his content. Btw, the user backend in Wordpress is still much better than Drupal. I's getting better, i.e. the D7UX project os awesome, but the average user can still work easier with Wordpress than with Drupal. I know many custom papers. They usually don't have lots of functionality in their site. They tend to be crappy content providing pages. But for that reason there are tons of SEO plugins for wordpress.
I love Durpal for the total package, it's better than the rest, but i don't think it is the best system in every single aspect.
23rd Jun, 10
Hey guyz,
How Search Engine Optimization helps improving websites can anybody explain me..and what are those Backlink,Directory Submission and article submissions..
Thanks
Post new comment