Posts Tagged ‘seo’

How To Hide Links To Avoid NoFollow PageRank Sculpting Issues

Saturday, June 6th, 2009

Just recently Google’s Matt Cutts announced a change in how Google handles NoFollow attributes in links thus making a “rel=nofollow” useless on your JavaScript-enabled onClick event handlers. The best method in this case would be to hide links on your page that you would normally have used “nofollow” on so you could only show them via JavaScript.

Instead of using “rel=nofollow” on your links as you did previously you may want to hide the links completely and only make them appear when JavaScript is enabled. You should also show a user which does not have JavaScript enabled that there is a link but it is not enabled. So I decided to create a small JavaScript which converts <span> elements with a specific class name to links when the user has JavaScript enabled. If there is no Ja

vaScript the “links” will look like this:
followlink_1

If JavaScript is enabled and the page has finished loading the links will look like this:
followlink_2

This is the HTML code for the <span> tag which will be converted into a link which needs to be given as the title attribute of the element:

1
<span class="hiddenJSLink" title="http://www.saschakimmel.com/">Hidden Link</span>

This is how the link will look after the script has been executed:

1
<a href="http://www.saschakimmel.com/">Hidden Link</a>

You can also add both an id and additional classes to the source <span> – they will be copied to the final link.

The script requires the prototype.js JavaScript framework – I am using this because I know that many websites are already using it on their pages.

This is some code of an example HTML page – you can download it and the JavaScript file in a package below.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
<head>
<title>Hidden Links</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="hiddenLinks.css" type="text/css" />
<script type="text/javascript" src="prototype-1.6.0.3.js"></script>
<script type="text/javascript" src="hiddenLinks.js"></script>
</head>
<body>
<ul>
<li><a href="http://www.saschakimmel.com/">Normal Link</a></li>
<li><span class="hiddenJSLink" title="http://www.saschakimmel.com/">Hidden Link</span></li>
</ul>
</body>
</html>

So in essence the only thing you need to do is to add these three lines of code to the <head> section of your HTML file after you have downloaded the JavaScript/HTML/CSS package below:

1
2
3
<link rel="stylesheet" href="hiddenLinks.css" type="text/css" />
<script type="text/javascript" src="prototype-1.6.0.3.js"></script>
<script type="text/javascript" src="hiddenLinks.js"></script>

Acessibility Notice!

Please note that from an accessibility standpoint using JavaScript is not recommended as it renders the links useless on screen readers. But currently there seems to be no other way to hide links from Google for legitimate PageRank sculpting.

License

Creative Commons License
This code by Sascha Kimmel is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License. This means that if you are using it on your site (personal and commercial sites are ok) you need to add a link somewhere (only on one page)  as provided here:

1
HiddenLinksJS by <a href="http://www.saschakimmel.com/" target="_blank">Sascha Kimmel</a>

If you don’t want to add a link to your site you can donate any amount to my PayPal account which will entitle you to use the HiddenLinkJS on any page without any requirement for adding a link:


View hiddenLinks.js
View hiddenLinks.css
View hiddenLinks.html demo page

dlnow

Saving Link Juice With Nofollow For The “Twitter for WordPress” Plugin

Wednesday, May 20th, 2009

I have just recently enabled the Firefox Addon SearchStatus while on my blog’s homepage. I was amazed that the Twitter For WordPress plugin doesn’t add rel=”nofollow” to the My Latest Tweets widget (see on the right in the sidebar).

Therefore I have just added the corresponding code to the plugin’s PHP file and thought I should share this information because it might really be useful for other people.

Adding rel=”nofollow” to the Twitter links

First make a backup of the file wp-content/plugins/twitter-for-wordpress/twitter.php and save it as twitter.org.php in the same directory. Afterwards open the file twitter.php and modify the code as highlighted here. You need to scroll to the right to see the highlighted code:

function hyperlinks($text) {
    // match protocol://address/path/file.extension?some=variable&another=asf%
    $text = preg_replace("/\s([a-zA-Z]+:\/\/[a-z][a-z0-9\_\.\-]*[a-z]{2,6}[a-zA-Z0-9\/\*\-\?\&\%]*)([\s|\.|\,])/i"," <a rel=\"nofollow\" href=\"$1\" class=\"twitter-link\">$1</a>$2", $text);
    // match www.something.domain/path/file.extension?some=variable&another=asf%
    $text = preg_replace("/\s(www\.[a-z][a-z0-9\_\.\-]*[a-z]{2,6}[a-zA-Z0-9\/\*\-\?\&\%]*)([\s|\.|\,])/i"," <a rel=\"nofollow\" href=\"http://$1\" class=\"twitter-link\">$1</a>$2", $text);
    // match name@address
    $text = preg_replace("/\s([a-zA-Z][a-zA-Z0-9\_\.\-]*[a-zA-Z]*\@[a-zA-Z][a-zA-Z0-9\_\.\-]*[a-zA-Z]{2,6})([\s|\.|\,])/i"," <a rel=\"nofollow\" href=\"mailto://$1\" class=\"twitter-link\">$1</a>$2", $text);
    return $text;
}

function twitter_users($text) {
       $text = preg_replace('/([\.|\,|\:|\¡|\¿|\>|\{|\(]?)@{1}(\w*)([\.|\,|\:|\!|\?|\>|\}|\)]?)\s/i', "$1<a rel=\"nofollow\" href=\"http://twitter.com/$2\" class=\"twitter-user\">@$2</a>$3 ", $text);
       return $text;
}

After you have added the code save the file, upload it you your server and you’re done.

If you are using the WP Super Cache plugin be sure to empty the cache so that all pages are updated.

tweetthis-15

Why WolframAlpha Should Hire An SEO

Sunday, May 17th, 2009

Although my first look at WolframAlpha was rather disappointing I didn’t really intend to show everything that’s not working as I had expected. However I stumbled upon problem after problem.

Now I didn’t intend to write this article at all but just searching for what Google has already indexed of WolframAlpha and following some links made it clear that they obviously didn’t think about SEO at all prior to launching their site.

The problem is: they are doing many things that  might actually harm their Google rankings that are just beginning to show up. We don’t yet know who will be using WolframAlpha in two months, if it will grow to become something that most of the people will use  just like Google or if it is going to fail like WikiaSearch.

Remember: they received over 1000 links to their site within two days and this is likely to grow so it makes sense to optimize the site now to prevent damage.

So from a logical point of view if I had been responsible for the WolframAlpha website I would not have done any of the following that WolframAlpha has implemented:

  • You Should Prevent No-Result Pages From Being Indexed
    “no result” pages return an 200 HTTP status code, not a 404 – Google will likely index these pages. The page doesn’t contain any META robots tag containing “noindex,follow” either.
    Because the differences between different “no result” pages depending on the query are only marginal this might be seen as duplicate content which you should never have on your own site.
  • Don’t Use Redirects For Loadbalacing
    Using the search field on the homepage now redirects via a 302 redirect to a hostname like “www18.wolframalpha.com” leading to even more duplicate content if Google indexes the same page with two different hostnames, e.g. www18 and www76. Normally you would be using a loadbalancer and not use HTTP redirects to distribute the load. They should at least be using the canonical tag to tell Google the original URL, but they aren’t, regretfully.
  • Use A Robots.txt File
    WolframAlpha is currently not using a robots.txt file so they are not telling search engines what should not be indexed.
  • Optimize The Clickthrough Rate In The SERPS
    The result pages do not contain a META description field which I would recommend for a higher click-through rate in the organic search results.
  • Use Text To Display Text, Not Images
    The title tag could also be optimized but I still don’t understand why even simple text is rendered as an image.

What do you think?

tweetthis-15

Must-Have Firefox Addons For The Developer

Monday, April 20th, 2009

Here is a list of Firefox addons for every web developer most of which I’m using almost daily. I can highly recommend any of these addons and I’ve been using most of them for a very long time.

Firebug

Nowadays I think I could just ask where you’ve been living for the past two years if you don’t know this must-have extension. Firebug allows you to debug your JavaScript code on your live website, to view and edit the HTML code and  CSS files on-the-fly directly for the current page and much much more.

Firebug also features am essential JavaScript console you can use in your own scripts for debugging and logging. Just check it out – it’s so essential that I won’t get into any more details here.

JSView

This cool addon adds a “JS/CSS” button to your browser’s status bar allowing you to see and view every single CSS and JS file that’s loaded on the current page. Sure – Firebug has the same feature, but using JSView actually makes this even easier than Firebug.

QuickJava

Quite often you have to check your own website to see if most of it still works if the user has JavaScript disabled. This addon adds to small buttons to your status bar which allow you to enable and disable both Java and JavaScript in your browser with one click. You still need to reload the page but this saves you from the tedious task of opening your browser settings each and every time you need to turn it off (or on).

HTML Validator

You should always make sure that your website contains only valid (X)HTML code and there is no easier way than installing this addon. This one also adds an icon to the status bar of your Firefox browser which is either a yellow warning sign, a green “ok” image or a red icon with a white cross indicating the validity of the code on the current website.

By double-clicking on that icon you are taken immediately to the source code view of the page including all of the warnings and errors that this addon has found in your code. Best of all – it checks everything offline, so it’s not sent to the W3C Validator and it’s very fast.

Live HTTP Headers

Sometimes you need to check the HTTP headers sent by your browser to the server or vice versa. This addon allows you to do just that and you can even apply regular expressions to the output so that you will only see what you are looking for.

Web Developer (Toolbar)

This is also a must-have addon just like Firefox which adds several features missing from your Firefox if you’re developing websites. Most often I’m using the “Find broken images” feature although this is just a very small part of this mighty tool.

ColorZilla

Sometimes you need (or want) to know the specific hexadecimal color code of a specific color on the website you’re currently on. ColorZilla adds a color picker to your browser and allows you to copy the color values directly to the clipboard so that you could insert it in your CSS file (that is what I am using it for most of the time).  And it still offers even more features that that.

MeasureIt

Draw a ruler to measure the width and height of any object on the current page.

SearchStatus

Would you like to know the current PageRank of the current website or the Alexa rank? This addon also offers additional features such as highlighting “nofollow” links and easy access to WHOIS and robots.txt information for the current domain.

SEOBOOK SEO  Toolbar

This is your ultimate SEO addon as it integrates as a toolbar into your Firefox browser and shows you almost anything of interest regarding SEO on any website. You can directly see the PageRank, Yahoo! backlinks, Yahoo! indexed pages, whether the current site is listed in the Open Directory Project (DMOZ), in the Yahoo! directory and so much more. You can even see the approximate age of the domain according to the first version indexed by the Internet Archive.

If you know any other cool addons for a web developer I would very much appreciate your comments and feedback.

tweetthis-15

Maintenance Page For Your WordPress Blog With Bots In Mind

Sunday, April 19th, 2009

I have just read this article from SmashingMag (#4) regarding a maintenance page for your WordPress blog which you could use while you’re upgrading or maintaining your blog. This quick hack is impressive yet it fails to take into account search engine bots.

Depending on how often crawlers like GoogleBot visit your website you should really think about your search engine rankings. Don’t forget: bots are not able to (at least not yet) understand the page they are accessing. If e.g. GoogleBot revisits your blog to index an article and finds a 302 redirect to your maintenance page this may lead to problems which in the worst case might mean that your maintenance page is being indexed and your previous article content lost for Google – at least as long as your maintenance page is up.

According to Google you should instead return a website with a 503 HTTP status code.

So let’s look at the original code by SmashingMag to put into your .htaccess file:

RewriteEngine on  
RewriteCond %{REQUEST_URI} !/maintenance.html$  
RewriteCond %{REMOTE_ADDR} !^123\.123\.123\.123  
RewriteRule $ /maintenance.html [R=302,L]  

The problem lies in the 302 redirect. So let’s just create a maintenance page telling GoogleBot to revisit our website in 30 minutes – you should of course add more informative text than I did to the page:

<?php
    $minutes = 30;
    header("HTTP/1.0 503 Temporarily Unavailable");
    header("Retry-After: ".$minutes*60);
?>
<html>
<head>
<title>Maintenance</title>
</head>
<body>
<h1>Maintenance - Please come back later in approximately <?php echo $minutes; ?> minutes.</h1>
</body>
</html>

Now the mod_rewrite rules in the .htaccess file need to be modified as well (assuming the file above would be saved as maintenance.php in the document root directory):

RewriteEngine on  
RewriteCond %{REQUEST_URI} !/maintenance.php$  
RewriteCond %{REMOTE_ADDR} !^123\.123\.123\.123  
RewriteRule $ /maintenance.php [L]  

That’s all – you’re done. After you have finished your maintenance work you just need to disable the rewrite rules by prefixing each line with a “#” symbol.

tweetthis-15