Welcome to WebmasterWorld Guest from 3.85.214.0

Forum Moderators: Robert Charlton & goodroi

Message Too Old, No Replies

How to hide content from Google in Ajax Lightbox

     
1:17 am on Jan 12, 2017 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member Top Contributors Of The Month

joined:Sept 14, 2011
posts:1045
votes: 132


I accidentally stumbled on a great way to hide content from Google.
I am sure this has many uses :)

Ok here what happened, I was using colorbox and loading lightboxes via ajax and I got kind of annoyed that Google would follow the ajax link and create a new web page so....

I removed the href link and replaced it with data-href

I changed the target file from .html to .txt

and added this in jquery


$(".ajax").colorbox({height:"80%",
width:"80%",
href: function() {
return $(this).attr("data-href");
}
});


Now the lightbox appears and works on page in full HTML but when google try to index the target file they get a TXT file that they can't index, result your content in the lightbox is invisible to Google
1:39 pm on Jan 12, 2017 (gmt 0)

Senior Member from GB 

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:Sept 16, 2009
posts:1087
votes: 83


I wouldn't be so sure.

First, read [ipullrank.com...] (Mods: hope this is OK, think I've seen it here before). This is from 2011.

If you accept the concept of a search engine spider that doesn't so much crawl code as visually render a page then coding conventions become unimportant. It's not the source code that is important. It's what the browser renders and the user sees that's important.

On a personal level, I have seen first hand an attempt (which failed) to do PR sculpting (May 2016) using encrypted navigation links. I didn't advocate the change but came along to a project after it had been done. I reviewed a number of metrics that would be different were Google now unable to see thousands of links to hundreds of thousands of pages - links it had previously crawled and sent PR through. All metrics were identical pre and post change.

Here's the code: <span class="" data-lnk-url="hexcodehere"> - not even an href.

I realise that the context is different but the point remains. There are exceptions (nofollow for example, an endorsed method to label links), but the point is this: Google's aim is to see content as content - no matter the method used to render it in the browser.
11:41 pm on Jan 12, 2017 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member Top Contributors Of The Month

joined:Sept 14, 2011
posts:1045
votes: 132


Totally agree FranticFish, Google renders googlebot in some form of stripped down browser, and has the ability to index all the rendered code. However what they do with ajax is follow the link to the content and index that page instead. That's all well and good when you have a page that renders in the browser but in this case scenario its txt files that don't render as html in the browser. And yes I am aware google will occasionally index .txt files but its rare and in all cases I have seen of .txt files indexed none contain html code.

So Google have a choice, ignore the txt files and allow the hidden content. Follow the txt files and show fragmented code to its users, or render the ajax page as intended with the txt content on showing up on the source page (which is what I originally intended).
9:23 am on Jan 13, 2017 (gmt 0)

Senior Member from GB 

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:Sept 16, 2009
posts:1087
votes: 83


So, are you saying that - unless you use this method - Google will either:
- index the content on the separate 'fragment' url; or
- not index it at all?

Did you try 'noindex' on the fragment page to see if the content was attributed to the main page in that instance?
6:55 pm on Jan 13, 2017 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member Top Contributors Of The Month

joined:Sept 14, 2011
posts:1045
votes: 132


So, are you saying that - unless you use this method - Google will either:
- index the content on the separate 'fragment' url; or
- not index it at all?


Google will index fragmented html as separate urls for ajax, bit disappointing in that it creates a bad user experience to have ajax loaded html on a seperate url

Did you try 'noindex' on the fragment page to see if the content was attributed to the main page in that instance?


I did think about this method, my concern was when google renders the html on the on the main page it will get a noindex , not sure how it would treat that. Another thought was to put ajax content in a folder and then using robots.txt to disallow the folder.

At present, Google is completely ignoring the .txt files so this has become an accidental way to hide content
9:34 am on Jan 14, 2017 (gmt 0)

Senior Member from GB 

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:Sept 16, 2009
posts:1087
votes: 83


Understood - I didn't realise from your initial post that Google was splitting the content between the two urls. Just so I'm clear, is your intention to have the AJAX content indexed or not indexed?
8:06 pm on Jan 15, 2017 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member Top Contributors Of The Month

joined:Sept 14, 2011
posts:1045
votes: 132


The intention was to have ajax indexed on the main page.

The conclusion I have drawn from this is Google is not ready for ajax, to fix Google and have the content indexed I have switched back to .html file extensions, turned the fragmented html into a full html page and then used display:none on elements (like menu) when calling the code via ajax.

Not what I hoped for at all and not what ajax is intended for. Google have effectively made ajax a liability at present :(