Saturday, May 14, 2011

How to add a "nofollow" attribute to all affiliate links on your WordPress blog


Google recently updates the algorithm it uses to rank web sites. One possible solution for this is to add the "nofollow" attribute to all paid or affiliate links on your web site. If you're using WordPress there's an easy way and a hard way to do this. I'll show you both below.

Background

In theory, the change is good news for honest web publishers and readers alike, since the stated goal of the project is to filter out paid links and "content farms" with high quantity, low quality articles.

Unfortunately a number of web sites got caught in the cross fire, despite publishing gobs of original content and staying away from paid links. It looks like there might be a relatively simple explanation for this: affiliate links.

There's a difference between a web site trying to game Google's search results by purchasing paid links on web sites and bloggers posting a little affiliate code when linking to a product on Amazon or another web site -- especially if it's a link they probably would have posted anyway. After all, why not earn a small commission when someone clicks your link to Amazon and makes a purchase if you were writing an article explaining that a new laptop is available or deeply discounted from the web store anyway?

The problem is that Google's algorithm isn't really able to tell the difference between these two types of links -- not without a little help. That's where the "nofollow" attribute comes in. Basically, by adding rel="nofollow" to a link, you're telling Google to ignore a link when making decisions regarding search results ranking.

In other words, one of the things Google looks for when determining which sites are the most trusted is the number of links to that web site from other web sites. If thousands of sites link to Amazon.com, then Amazon must be a relatively well trusted site. But if your web site is filled with links to Amazon and most of those links include affiliate code, Google might get the idea that you're being paid to promote Amazon and you're linking to the site for that reason, rather than because you trust it. Google might also decide that since you take money to post links, your site might not be all that trustworthy, and you can wave goodbye to traffic from Google.

By adding the nofollow attribute to any paid or affiliate links, you're telling Google to just go ahead and ignore those links, which means you're not being paid to goose anybody's search engine traffic.




How to add the nofollow attribute manually


To add a nofollow attribute, you'll want to take a look at the HTML view for your web site. Odds are your links will look something like this:


In order to add the nofollow, just insert rel="nofollow" so that the link now looks like this:


Seems easy enough, right? It is... if you only want to do this on all new links. But things get a lot more complicated if you already have hundreds, or even thousands of links that Google may be counting against you.

You could try to find each post on your site with affiliate links and edit them one by one, but there is an easier way.

How to add nofollow links to every WordPress post in a category using [de77] No-Follower


There's a free plugin for WordPress called [de77] No-Follower which lets you add a nofollow attribute to every link in every article in a certain category.

All you have to do is install the plugin, then go to the No Follower plugin settings, choose a category, and hit "save changes"



What I did was set up a new category in WordPress called "nofollow." You can do this by clicking the Posts menu, then the Category submenu and then simply filling out the add new category box.

Editing links this way is actually a good idea because most WordPress plugins you use to perform a batch job only work so long as the plugin is installed and functioning properly. But it could take weeks to identify and manually edit every link on the site, so I figured there had to be an easier way. I was right.

Putting it all together - Searching for affiliate links and adding "nofollow" attributes in batch edits


OK, so if you have hundreds of articles with affiliate links, it might be tricky finding them all. I had a head start because I've been running a series called "Deals of the Day" for the past few years, and every post was tagged "bargains," which made those posts easy to find. But it turns out there were hundreds of posts with affiliate links that weren't in the daily bargains articles. So here's the system I came up with to find and edit all affiliate links as quickly as possible.

First you'll want to identify words that show up regularly in your affiliate links. For instance, most of my Amazon affiliate links include "bradlindsdigi-20" in the URL. If you performed a search for that term in Google you wouldn't get very many results. But using my internal WordPress search, hundreds of articles showed up. If you use Commission Junction, LinkShare, or other popular affiliate networks you can do the same thing by searching for your publisher ID. Most LinkShare URLs, for instance, include the word "linksynergy."

You can also manually search for the names of stores you know you sometimes link to. Note that sites such as J&R and B&H are easiest to search for in WordPress if you change the ampersand so that instead you search for B&H and J&R.

Once you have [de77] No-Follower installed and have a list of affiliate link terms to search for, it's time to get started.


  1. From the WordPress admin menu, select Posts.
  2. Enter your first search term in the search box and then hit "Search Posts."
  3. You're now looking at a page that should contain posts with your affiliate link code. You might want to double check a few posts to make sure though.
  4. By default, WordPress will probably display 20 results. If you want to increase the results listed on each page, hit the "Screen Options" button near the top right side of the screen and change the number of posts. You probably won't want to set the number too high or you might run out of memory, but 30 or 40 should be safe. 
  5. Click the box next to "Date" to select every article shown on the page.
  6. From the "Bulk Actions" drop-down box, choose "Edit" and then hit the "Apply" button.
  7. You should see a list of posts to be edited and a number of options -- but the only one we care about right now is the category.
  8. Check the box next to the category you want to add. In my case, I chose "nofollow."
  9. Click the blue "update button."
  10. It will take a moment for the page to refresh since you just asked WordPress to process 20 or more posts at once.
  11. When it's done you should see a yellow bar with a message letting you know the posts have been updated.
  12. If there are more than 20 posts, you should see navigation menus near the top right letting you move to the next page. 
  13. Repeat as necessary.
I identified about half a dozen affiliate link keywords for my web site and added every post I could find using those terms to the "nofollow" category. In the end, 852 of the 6982 posts published on Liliputing are now in the "nofollow" category which means that every link from each of those articles has been updated to include the "nofollow" tag.

Some of those articles include links that aren't affiliate links, so this method isn't perfect. But it takes a lot less time to perform batch jobs than to individually adjust the links on 852 different articles. 

There are also WordPress plugins that would simply allow you to mark every single link on your entire web site as "nofollow," but that's not a very neighborly thing to do. Odds are if you publish a popular blog, you got where you did because people linked to your site regularly. How would you like it if every one of those web publishers told Google to ignore their links to your site? 

I think identifying articles with affiliate links and marking just those articles as nofollow is a better approach.

3 comments:

Nizam Khan said...

Indeed an excellent post, it is really helpful. Thanks for sharing :)

Malcolm Simmonds said...

That's a good tip. Might help me when i check back through old articles - which I'll have to do, darn it!


Cheers, Malc

CarleenPruessCoulter said...

This is absolutely awesome! I was looking for an easier way to do this than manually editing hundreds of posts. Thanks!

acelebration of womens khong familys mi sitios de diseno my site cheap technology museum planners new cesar dubo weddings and hair styles sim flecks iphones chile new phones blog