How to Remove the "Username's Blog" Link from Your Drupal Blog

And improve its search engine friendliness


How to Remove the "Username's Blog" Link from Your Drupal Blog

by Christopher Heng, thesitewizard.com

One of the benefits of using Drupal is that it supports multiple sites on a single installation. Unfortunately, this ability also creates annoyances for people who only want to use Drupal for a single blog. One such annoyance is that the Drupal blog module creates a "username's blog" link at the bottom of every post, on the main page, the post article page as well as every category page. This article briefly describes how you can remove the "username's blog" caption from your blog post.

This article was written in 2008 and describes an old version of Drupal. As such, the technique described here may no longer be applicable to the Drupal versions of today.

Why Remove The "Username's Blog" Link?

Visitors who write to me at thesitewizard.com asking about how they can remove the "username's blog" link usually want to do it for one or more of the following reasons:

  1. Aesthetic reasons

    Some of them find the link inappropriate in their theme. Others dislike having their blog described with their cryptic user name when they have taken the trouble to give a proper name / title to the blog.

  2. Duplicate Content

    A few users, after reading my article on duplicate content issues and its related search engine complications, are worried that since their site only has a single blog, the "username's blog" link points to a page that is identical with their main page.

Steps to Getting Rid of the Username's Blog Link

If you were to try to search through Drupal's theme / template files, you will find that you cannot cleanly remove the code that produces this specific link by modifying those files. Removing the line that prints the $links array also removes other links that you may want. This applies to both Drupal 5 and 6.

To surgically remove this link, and only this link, you will need to modify a file in the core Drupal installation.

  1. Go to the modules/blog folder in your Drupal files.

  2. Open the file blog.module in an ASCII/plain text editor. Do not use a wordprocessor.

  3. Search for the block of lines beginning with "blog_link" in the file. It should look something like the following:

    /**
    * Implementation of hook_link().
    */
    function blog_link($type, $node = NULL, $teaser = FALSE) {
      $links = array();

      if ($type == 'node' && $node->type == 'blog') {
        if (arg(0) != 'blog' || arg(1) != $node->uid) {
          $links['blog_usernames_blog'] = array(
            'title' => t("@username's blog", array('@username' => $node->name)),
            'href' => "blog/$node->uid",
            'attributes' => array('title' => t("Read @username's latest blog entries.", array('@username' => $node->name)))
          );
        }
      }

      return $links;
    }

    (For those familiar with PHP programming, basically, just search for the blog_link() function.)

  4. Comment out the heart of the function as follows:

    /**
    * Implementation of hook_link().
    */
    function blog_link($type, $node = NULL, $teaser = FALSE) {
      $links = array();
    /*
      if ($type == 'node' && $node->type == 'blog') {
        if (arg(0) != 'blog' || arg(1) != $node->uid) {
          $links['blog_usernames_blog'] = array(
            'title' => t("@username's blog", array('@username' => $node->name)),
            'href' => "blog/$node->uid",
            'attributes' => array('title' => t("Read @username's latest blog entries.", array('@username' => $node->name)))
          );
        }
      }
    */
      return $links;
    }

    The changes to make are highlighted in red in the code above. Specifically, put a "/*" (without the quotes) after the line "$links = array();" and a "*/" (without the quotes) on the line before "return $links;".

  5. Since you are modifying a core Drupal module, every time you update Drupal, you will need to remember to add your modifications to the "modules/blog/blog.module" file.

That's it. Reload your blog and you will find that the "username's blog" link is now gone.

Copyright © 2008-2014 by Christopher Heng. All rights reserved.
Get more free tips and articles like this, on web design, promotion, revenue and scripting, from https://www.thesitewizard.com/.

thesitewizard™ News Feed (RSS Site Feed)  Subscribe to thesitewizard.com newsfeed

Do you find this article useful? You can learn of new articles and scripts that are published on thesitewizard.com by subscribing to the RSS feed. Simply point your RSS feed reader or a browser that supports RSS feeds at https://www.thesitewizard.com/thesitewizard.xml. You can read more about how to subscribe to RSS site feeds from my RSS FAQ.

Please Do Not Reprint This Article

This article is copyrighted. Please do not reproduce or distribute this article in whole or part, in any form.

Related Pages

New Articles

How to Link to This Page

It will appear on your page as:

How to Remove the "Username's Blog" Link from Your Drupal Blog





Home
Donate
Contact
Link to Us
No Spam Policy
Privacy Policy
Topics
Site Map

Getting Started
Web Design
Search Engines
Revenue Making
Domains
Web Hosting
Blogging
JavaScripts
PHP
Perl / CGI
HTML
CSS
.htaccess / Apache
Newsletters
General
Seasonal
Reviews
FAQs
Wizards

 

 
Free webmasters and programmers resources, scripts and tutorials
 
HowtoHaven.com: Free How-To Guides
 
Site Design Tips at thesitewizard.com
Find this site useful?
Please link to us.