Sunday, June 3, 2007

Remove NoFollow from Classic FTP Blogger



Blogger Style:



Working with:





Blogger by default, and other blogging software such as WordPress, automatically adds the "nofollow" microformat extension to all links from user generated content. User generated content is defined as comments or external sources such as linkbacks and trackbacks.

I follow, do follow, no nofollowI support the people of the blogging community who have chosen to remove NoFollow for blog comments and linkbacks/trackbacks. If you are reading this right now, you too are probably thinking about joining us yourself. It would be a good move, read on to find out why.

If you are using the New Blogger Layout style on Blogspot, then you will need to use the Remove Nofollow from Blogger Layouts tutorial instead. This tutorial is for Classic FTP Blogger pages only.

Before We Begin


This removal procedure applies to the Classic FTP Blogger only. It is impossible, at this time, to remove NoFollow from Classic Blogger templates that are hosted at Blogspot. This is due to the fact that those templates use the variable <$BlogCommentAuthor$> which encapsulates the anchor link around linking text. Outside of petitioning Blogger to allow us the option for using "NoFollow", there is nothing that can be done.

This article also assumes that you have enabled your Html pages to process PHP script. If you have not done so already, visit the Parsing Html as PHP article before proceeding.

Nofollow Removal Process


The process to remove NoFollow is two-pronged and involves working with your template at Blogger and FTP access to upload a small PHP script.

We will first create an includable PHP script and FTP that to your server. The PHP script will do the actual work of stripping the rel="nofollow" attribute from your links.

In order for your the script to be processed, we will be revising your template to insert a few PHP directives. Also, we will isolate the portion of your code where the <$BlogCommentAuthor$> variable appears in your comments area and capture that variable into one that is recognizable by PHP.

Let's get started.

Creating the PHP Script to Remove NoFollow


I created an includable PHP file named pfblogger_functions.php. Inside of this file is a function named strip_nofollow(). There is another function in the file and more will be added as time progresses. All you need to concern yourself with is just the one function for right now.

Open up the blogger functions script in your browser. Using your favorite Html editor or Notepad, create a new file. Copy and paste the text from your browser screen into the new file, and save it with a name of pfblogger_functions.php

Upload the new PHP file via FTP to your server. I suggest uploading it into your "includes" directory if you have one. If not, then create a new directory on your server with the name of "includes". It keeps things neater this way.

Now that you have your PHP file installed, let's get on to the fun part!

Hacking PHP into your Blogger template


This portion of the tutorial may look a little daunting, but it really isn't. Just take your time and doublecheck your work.

Warning: Before beginning this procedure -- backup your template.

Navigate through your Blogger dashboard to Template > Edit Html

At the very beginning of your template, insert the following code:

<?php 

define('IN_PFBLOGGER', true);

<MainPage>
$site_rootpath = "../";
</MainPage>

<ArchivePage>
$site_rootpath = "../../";
</ArchivePage>

<ItemPage>
$site_rootpath = "../../../";
</ItemPage>

include ( $site_rootpath . "includes/pfblogger_functions.php" );

?>

Everything between the <$php ... $> markers will be run through the PHP interpreter on your server. The define statement at the beginning is for hacking security.

The rest of the code uses Blogger Conditional Tags to establish the actual path to your domain root and stores that in a variable. That variable is used with the path to your include file. If the your path to the function file is different, revise this portion of the code accordingly.

We have now properly included our function file, now let's proceed to the good part.

With your template do the following:
Find:
<$BlogCommentAuthor$>

and replace with:
<?php strip_nofollow( '<$BlogCommentAuthor$>' ) ?>

Find:
<$BlogCommentBody$>

and replace with:
<?php strip_nofollow( "<$BlogCommentBody$>" ) ?>



UPDATE: The code that acted on the comment body worked fine until somebody used a 'double quote' in their comment. This was due to the fact that I enclosed the variable <$BlogCommentBody$> with double quotes and it broke the code. I am working on a fix. If you have installed this hack, then revert this portion of the code back the way it was.

Save Template Changes, but do not replish just yet. We want to test that everything went as planned first.

Navigate to Posting > Create and enter a Test Post. Publish the post and view your blog in your browser.

Enter a comment for the post. Go back to view the post and verify that your Comment Author link is now free of the NoFollow attribute. You can verify this by several means -- one is View > Page Source from your browser menu. If you are using Firefox, there are extensions and other menu options for viewing/identifying links that have Nofollow attributes.

One last step


In order for this change to have any effect, you will have to republish your entire blog. This will rewrite all of the Main, Item and Archive pages with your new code. If your blog is large, a few hundred posts or more, this could take quite a while to process.

If you choose to delay republishing, any new comments made to your posts (existing posts included) will have the NoFollow removed from now on.


Optional NoFollow Recommendations


Now that you are a card carrying member of the Anti-NoFollow community, would you like to hook up with other blogs that share this belief? Then join us over at BUMPzee in the No Nofollow I Follow | DoFollow community.

This NoFollow community is headed up by Andy Beard and is growing everyday. The response has been phenomenol. With hundreds of participating blogs, odds are you will link up with many blogs who share in your particular interests.

17 comments :

Update Dubai said...

hey, Joined Bumpzee after about 1 econd of thinking about it.

Blogging works because people link to each other. No follow stops that from working. Active blog owners should actively give and get more links than static page site owners.

Nofollow greatly reduces the links available for everyone by installing a shortage mentality. Truth is PR comes from pages So simply -> more blogs = more pages = more PR available

lumo said...

Hi Ronnie,
Good stuff and I agree that comments should be followable if there's such a word.

I'm new to this blogging stuff and are using I assume what people refer to as the "new" ftp blogger. Is that right?

Anyway the <$BlogCommentAuthor$> tag doesn't exist, they seem to be <$I18NCommentAuthorSaid$> now.

I tried surrounding it with ? php strip_nofollow( '<$I18NPostedByBacklinkAuthor$>' ) ? but of course its not that simple.

Any ideas?

Tips 4 Blogspot said...

Wow. This is first time that I have seen those Blogger variables. I am going to look into them, most definitely.

But you are correct, it is just that easy to wrap the coding for php function strip_nofollow around the variable.

One caveat -- the function does not work on body comments in the present state, due to quotes in the comment will break it.

I have just rewritten the function and the template code, and that problem is now overcome. Will post the solution later this evening, along with thoughts on the new variables.

To see it in action, visit the test posting page

Tips 4 Blogspot said...

Lumo -- what I found so far, is that is an Internalization variable (i18n). I cannot find any documentation from Blogger on it.

From a quick perusal of some of the Classic Templates the usage appears to be the same. I am assuming that it functions just like the <$BlogCommentAuthor$> variable then, and it should work.

If you can confirm that the hack will work, then I will annotate the tutorial to account for it. Seems there are a number of blogs with that type of variable in them (via BlogSkins) and it would be nice to include the information for their sake.

lumo said...

Nope, this doesn't do the trick,
I'm pretty sure everything is plugged in as it should be, pfblogger_functions.php on server,
define in the head and the php strip_nofollow surrounding the <$I18NPostedByBacklinkAuthor$> but it still returns rel="nofollow" links.

To check that I haven't done something silly as soon as you publish the body comments fix I'll test again as that variable tag is the same as the older templates.

(Or is it newer templates? I'm totally confused as to the timeline of old blogger, new blogger, classic blogger etc :)

Tips 4 Blogspot said...

The only thing I can think of right now,is did you do the .htacess?

I am pretty sure you allowed your Html pages to be processed as PHP. Just want to verify.

If this does not work .. contact me at webstractions[at]gmail.com

LGR said...

Interesting discussion. Are there any errors in your error log? Perhaps there is something there that could help with diagnosing the problem.

Tips 4 Blogspot said...

@LGR - I have already asked Lumo why the Error Messages are not showing up on his blog via Email. Have not received confirmation on that yet, but I suspect that his Php INI file may be suppressing them in some manner.

If you are trying to attempt using this hack, and are having problems, please contact me at webstractions[at]gmail.com

I would appreciate any input you have to offer.

harleyblues said...

ok Im a bit confused can I do this to my blog? pls let me know and is there a simplier way for a newbie like me

http://harleyblues2007.blogspot.com/

any hep would be appreciated

hb

Tips 4 Blogspot said...

@harleyblues - You are using the New Layouts for Blogger. Please refer to to Removing Nofollow from New Blogger and yes, it is fairly simple to do.

One caveat is that only the Author Name link is hackable. Links in the comment body cannot be hacked.

And I love the Beatles! Nice to see some tidbits on Paul too. Keep up the good work.

SEO BB said...

You have these comments appearing in two places, one followed, one nofollowed, is that how it's supposed to be?

BB

Tips 4 Blogspot said...

@seo_bb : Sadly yes. The commenting form is part of Blogger and cannot be altered. The listed comments there are nofollow. Coincidently, they are not indexed either (not to my knowledge anyway).

The Main Item page which displays comments at the end will have the nofollow removed from the Author's link and the body of the post in Classic FTP Only.

SEO BB said...

tips4blogspot said "The commenting form is part of Blogger and cannot be altered. The listed comments there are nofollow. Coincidently, they are not indexed either (not to my knowledge anyway)."

Um, But the links to names attached to comments are followable from at least one part of the blog? I think that's ok from an SEO perspective as I don't believe a gazillion links from one domain are going to do you more good than one will. Just as well probably otherwise you'd go back to the days of idiots autoposting over and over.

BB

Tips 4 Blogspot said...

Correct, the Item Page for this post has the Author Links that is followable.

And I think whether or not there is merit in posting a link more than once will deter the idiots ... after all, that is why they call them idiots. ;-)

Dan O'Neil said...
This comment has been removed by the author.
Dan O'Neil said...

I've also tried to surround the <$I18NPostedByBacklinkAuthor$> tag and it hasn't removed the nofollows. Any further ideas on this?? Thanks

Dan O'Neil said...

I'm not sure if you still maintain this site as there seems to have been no activity for a few months... anyway... I realised that surrounding the <$I18NPostedByBacklinkAuthor$> tag was pointless as this is for the backlinks section not the comments. So I've re-jigged the comments bit and used the tags that everyone who has had success is using, it all works fine until... I surround the <$BlogCommentAuthor$> tag with the php strip... then I get the following error...

Parse error: syntax error, unexpected T_STRING in ... then a filename and line number...

Any ideas on this anyone?