Yashar Ghaffarloo

Ramblings of an internet marketer

The Better Way to Hide Links from SEO Crawlers

It’s no question that hiding links is critical to any successful SEO campaign.

When building links, especially on PBNs and the like, it’s important to block SEO crawlers like Ahrefs (ahrefsbot) and Majestic (MJ12Bot). Most SEOs accomplish through abhorrent .htaccess lists of bots to block.

what are all of these bots anyway?

The current solutions are…

  • .htaccess files
    • Not always applicable if you don’t have full control over the site
    • Often times blocked from being edited
    • Require some technical know-how, updating, and blind trust
    • Footprint if set up incorrectly
      • Blind trust / copying pasting code you find online is bound to lead to problems
  • robots.txt
    • (lol)
  • WordPress plugins
    • Not so great if you’re not using WordPress
    • Require blind-trust in the author of the plugin
    • Footprint if (when) set up incorrectly (more on that in another post)

Using Javascript, we can abuse the achilles heel of crawlers and have links “hidden” in the source code of a site, but visible on the page load.

This is what the SEO crawlers will see (no visible links), but here is what Google will see.

Because we broke the link up into two parts (variable a and variable b) and combined the variables when the page loaded, we were able to hide our link from third party SEO crawlers.

This requires little to no technical knowledge and relies on simple Javascript. No sneaky redirects or cloaking.

This is helpful for those who are also building links on public facing properties and can place Javascript: most website builders and submission platforms allow Javascript embed within the HTML, but not access to .htaccess or robots.txt. Using this, you can block your competitors from viewing more than just your PBNs!

You can view the code for this here. Replace link with your anchor text, and replace the URL split among the two variables with your own.

After doing so, simply invoke your link by using <span id=“target”></spaninstead of the hyperlink HTML code.


Bulk Twitter Username Availability Checker


Crush CBD (Tinted Brew Inc.): A Laughable Attempt at Domain Name Hijacking


  1. James Rowland

    10 year SEO veteran and I’m learning something new from a 16 year old haha. Great post man.

  2. Armando

    Just value I love it thanks Yasher

  3. Stev

    Amazing.. Thanks for the share

  4. Shahin Akhter

    I am checking this here on your blog’s comment section.

    var a = “Trick“;

    document.getElementById(‘target’).innerHTML += a + b;

  5. Shahin Akhter

    Ok ???? code is working in Posts Sections only ….

    R&D in my Blood … he he

  6. Seo Surat

    Hi yasher..,, this is really amazing…. But still confused how to implement…. Since i m not good with codes…i could find htaccess file… Rest i m unsure….

    • yashar

      next time you try to score a link, please put in a bit more effort. implementation is described in the post and an example has been given as well.

  7. Zakirhusain Khatri

    Thanks yashar, this is amazing post. As I am coder i know how JavaScript will work at pageload. This is brilliant idea to hide Backlinks from competitors.

    • Peter Kim

      Hi, Tell me If I am wrong, I put JavaScript at ” page specific script” on WordPress Post and I put “You can simply put the here” at any where in my post. Thanks

  8. Ori Zilbershtein

    Obviously you need to block crawlers coming from your PBN to your money site, I would suggest even blocking the crawlers to the PBN sites also, just make it invisible completely, the .htaccess method is very efficient and I would not suggest using plugins, plugins are one of the ways usually sites gets spammed or hacked.

    • yashar

      There are pros and cons to all methods of hiding links. I agree with you that plugins are inefficient, but .htaccess has some problems due to its nature, even when “set up properly”.

  9. Benjamin Church

    Awesome post, thanks Yashar.

  10. Bjorn


    Nice trick Yashar- I’m unfortunately not a good coder, but I managed to get it to work on normal text links but I can’t figure out how to hide image links with this method.
    I have tried to add in the script but it does nothing.
    Hope you or another can help me out.

    Best regards

    • yashar

      The issue arises because you are using double quotes twice because you are including an image source URL in the image tag.

      Simply replace the inner double quotes with single quotes and you should be fine. Here is a code sample using a linked image: http://pastebin.com/B1k1WG1Y

  11. Erik

    Question from a technical standpoint.

    Do crawlers from Majestic, Ahrefs, Semrush, etc. crawl the site differently than Google?

    I just want to understand why it doesn’t impact Google’s ability to recognize the link.

    • yashar

      Yes. Crawlers such as Majestic, Ahrefs, and SEMRush only have the capacity to view the source code of the site and parse links from the source code (looking for the “a” tag).

      Google, however, can not only parse the source code of a page, but also render the page. The Javascript code above only renders links on page load, which prevents SEO crawlers from recognizing links.

  12. Alex D

    Thanks as always. Easy to understand for somebody like me with little coding experience 🙂

  13. Mark

    Amazing great post as always. Awesome theme too.

  14. Jahir Saabi

    Just now stumbled upon this, great post Yashar!

Leave a Reply

Powered by an unhealthy amount of caffeine. &

Yashar Ghaffarloo | Yashar Ghaffarloo | Yashar Ghaffarloo