Search code examples
javascriptgooglebot

How to make a js script Never executed by google bots


I have a small script which job is to change dynamically some letters in the titles of a web page. (It is done for graphic purposes, those letters are set in a "iconized" font, it's pretty nice ^^).

The problem is, Google indexes the page with the modified letters, and my content is full of words with bad letters ie. HELLO WFRLD

Is there any way to make a js script not executable by google bots ? I was thinking something like;

if(!window.googlebot && navigator.userAgent.indexOf(' GOOGLE/') !) {
    //script
}

Do you have an idea? Thanks


Solution

  • In robots.txt

    User-agent: Googlebot
    Disallow: maybeYourFile.js
    Disallow: .js