Google has announced that placing ‘nofollow’ tags in your links will drain your PR juice – thereby eliminating one of the major incentives to using the nofollow tag that Google created in the first place.
Google has also announced that it’s spidering robots can now follow Javascript links.
So how do you create links that Google cannot follow, thus preserving your valuable PageRank?
In a nutshell, by placing your links in an external JavaScript file that robots are blocked from accessing.
Here are the steps:
1. Include the following JavaScript code within the head section of your web page:
<script language=”JavaScript” src=”http://yourwebsite.com/yoursubdirectory/yourjavascriptlinksfile.js” type=”text/javascript”></script>
2. Prohibit robots from accessing your java subdirectory (or whatever you want to call it.
Include the following code within your robots.txt file:
User-agent: *
Disallow: /java/
3. Put your links in your javascriptlinks.js file.
Use this format:
function link1() { location.href=’http://firstlinkgoeshere.com’; }
function link2() { location.href=’http://secondlinkgoeshere.com’; }
If you want the link to open in a new window, use this format:
function link2() { window.open(’http://secondlinkgoeshere.com’); }
And so on. Give each link a unique number.
4. Include the JavaScript link reference within your html pages.
<div onclick=”javascript:link1()” style=”text-decoration: underline; color: blue; cursor:pointer”> Link 1 Description</div><br><br>
<div onclick=”javascript:link2()” style=”text-decoration: underline; color: blue; cursor:pointer”> Link 2 Description</div><br><br>
(note: if you copy code from this post and your link does not work, go manually into your files and change any ’smart’ or ‘curly’ quotation marks to regular quotation marks. )
If you are wondering, this is approved by Google. Matt Cutts at http://www.mattcutts.com/blog/what-did-i-miss-last-week/ refers to “doing an internal redirect through a url that is forbidden from crawling by robots.txt” to be an approved method of linking, such as for paid links, that do not affect search engine results.
This technique is also referenced at http://www.google.com/support/forum/p/Webmasters/thread?tid=4790fe490de7a55e with regards to how to prevent Google from indexing some content on your web page.
And here from the Official Google Webmaster Blog: http://googlewebmastercentral.blogspot.com/2011/11/get-post-and-safely-surfacing-more-of.html Google says even with its new improved abilities to index some JavaScript it cannot index anything using this method.
Extra Tip:
Instead of using the ’style’ code in your page link, you can use a php include file that contains this information. Interesting to use php within javascript, but it works. This way you can have your link styling and a common description if you want, in a separate file, so if you want to change it you only have to change the php include file and not every link on every page.
Link to this page
Entries (RSS)
Hi Brian,
do you know how to do this on a wordpress blog? I.e., where you put the part of the thing that goes in the header file?
Or won’t it work on a WP blog?
Thanks!
Elisabeth
Elisabeth, there is no difference between using Wordpress and an html built website. You follow the same steps for creating your links.