How can I create javascript links so that Google doesn't recognize them as links?

I want to create links to images through javascript in such a way that Google does not recognize them as links. Any useful answer would be noticeable.

Thanks!

+4
source share
4 answers

The correct way to send a signal to the search engine is not to bypass the link using ref='nofollow'

 <a href="http://www.example.com/" rel="nofollow">Link text</a> 
+5
source

Why do you need this? If you do not want Google to index certain parts of your web page, try placing robots.txt in the root folder.

In this file you can specify the search engines which folders they should index and which not.
http://en.wikipedia.org/wiki/Robots_exclusion_standard

If any other page on the Internet links to a page hidden behind links, this will be enough for Google to find and index it.

+2
source

I'm not sure what you mean by "don't recognize", but if you want to "hide" the actual URI, you can bind the click event handler to the node anchor and redirect the browser through location.href .

 document.getElementsByTagName( 'a' )[ 0 ].addEventListener('click', function( e ) { location.href = this.getAttribute( 'data-myurl' ); e.preventDefault(); }, false); 

Actual HTML markup will look like

 <a href='#' data-myurl='http://www.google.com'>click me</a> 
0
source

If you really don't need / need links (rollback for users without javascript), you can simply remove the link tags and add click handlers to the images.

front:

 <a id="my-link" href=".."><img src="..."></a> <script> document.getElementById('my-link').onClick = function() ... </script> 

after:

 <img id="my-link" src="..."> <script> document.getElementById('my-link').onClick = function() ... </script> 
0
source

All Articles