Search code examples
htmlcssseo

How to tell google bot to skip part of HTML?


There is much info about opposite situation, when people try to have stuff in HTML, that is visible to Google bots, but not visible to users, in my case, I need opposite thing - to hide some of the html from google bot. The question would be how?

Flash is not an answer,
Would prefer not to use fancy ajax things also (mainly because I need it right away, not on document ready),
Also robots.txt is not an answer, because it works on urls, not parts of the page. Would any special css/simple javascript work, is any special html tag for this?


Solution

  • Maybe a base64 encoding server side and then decoding on the client side could work?

    Code:

    <!-- visible to Google -->
    <p> Hi, Google Bot! </p>
    
    <!-- not visible from here on -->
    <script type="text/javascript">
    document.write ("<?php echo base64_encode('<b>hey there, user</b>'); ?>");
    </script>
    

    How it looks to the bot:

    <!-- visible to Google -->
    <p> Hi, Google Bot! </p>
    
    <!-- not visible from here on -->
    <script type="text/javascript">
    document.write (base64_decode("B9A985350099BC8913=="));
    </script>