How to nofollow all external links in Blogger

Yes, you can add a nofollow tag to every external link on your Blogger blog automatically, with one small piece of code. You paste it once in your theme, and from then on every link that points to another website gets rel="nofollow" and opens in a new tab. Your own internal links stay untouched. In this guide, I will show you the exact code, and explain when to use nofollow, ugc, and sponsored, so you pick the right one every time.

Are you a selfish blogger like me, who does not love to pass link juice to other blogs? Do you want to get rid of all the outbound link worries? Do you want to know how to add a nofollow tag to all external links automatically in Blogger? Then this guide is for you.

Outbound linking is really helpful for your blog visitors, because it gives them more information. For example, if you are writing about on page SEO and you mention a keyword that improves your traffic, you may want to show a proof that it really works. At the same time, a famous blogger has written a blog post that proves your statement. So you link to it, and your blog visitors get some more information.

If you are new to SEO, start with my guide on What Is SEO first. It explains the basics in plain words.

But what if a low quality and spammy blog wrote the proof of the above statement? Will you link to it and let Google think you trust it? Google says you should use nofollow when you would rather Google did not associate your site with the linked page. That is exactly what this guide is for.

Nofollow vs UGC vs Sponsored — Which One Should You Use?

Google gives us three values for the rel attribute. Pick the one that matches your link:

Value Use it for
rel="nofollow" Links where the other values do not apply, and you would rather Google did not associate your site with the linked page.
rel="ugc" Links in user-generated content, like blog comments and forum posts.
rel="sponsored" Links that are advertisements or paid placements.

You can also combine them, like rel="ugc nofollow". And here is one thing most bloggers get wrong: a plain link with no rel attribute is also fine. If you trust the site and you want Google to treat the link as a normal recommendation, leave it as it is. You can read Google's own words on this in their guide to qualifying outbound links.

How To Add Nofollow Tag To All External Links In Blogger

Here are the steps:

  1. Go to Blogger > Theme.
  2. Click the arrow next to Customize and choose Edit HTML.
  3. Search for </head> and paste the code below just before it.
  4. Click on Save.

Blogger Theme Edit HTML screen showing the theme code editor
Source: Blogger Theme editor

First, add jQuery to your theme. Skip this part if your theme already loads jQuery:

<!-- Skip this if your theme already loads jQuery -->
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>

Then add this code just before </head>:

<script>
jQuery(document).ready(function() {
  jQuery('a[href^="http"]').each(function() {
    if (this.hostname && this.hostname !== location.hostname) {
      jQuery(this).attr('rel', 'nofollow noopener');
      jQuery(this).attr('target', '_blank');
    }
  });
});
</script>

This snippet is based on the classic MyBloggerLab code, updated for today's Blogger: the jQuery file now loads over HTTPS, and the selector works for both http and https links.

What This Code Does

The code checks every link on your blog. If the link points to another website, it adds rel="nofollow noopener" and opens it in a new tab (target="_blank"). If the link points to your own blog, it leaves it alone. The code compares each link's address with your blog's address, so you do not have to edit any domain name inside it. The noopener part is a small safety extra for links that open in a new tab.

Why Nofollow All External Links

Avoid Passing Link Juice to Spammy Sites

With a nofollow tag, you tell Google not to associate your site with the linked page. So when you need to link to a low-quality page to give your readers more information, you can do it without passing your endorsement to it.

Keep Readers on Your Blog

The target="_blank" part opens every external link in a new tab, so your blog stays open in the reader's first tab. That is a small comfort for your readers. It does not raise your rankings, and it does not raise your CTR or CPC. No code can promise that.

Will adding nofollow to all external links hurt my blog's SEO?

No. Google itself tells us to use nofollow when we do not want our site associated with the linked page. It only stops Google from treating the link as your endorsement. Your own blog is not penalised for using it.

Do I still need this if I only link to good websites?

No. If you trust a website and you want to recommend it, a plain link with no rel attribute is the right choice. Use nofollow only for the links you do not want to vouch for.

Will this code nofollow my internal links too?

No. The code checks the address of every link against your blog's own address, and it skips the ones that belong to your blog.

What about the links in my blog comments?

For comment links, Google recommends rel="ugc", not nofollow. I have a separate guide on how to make Blogger comment links dofollow. It now uses rel="ugc", which is what Google recommends for comments.

Conclusion

In this way, you can add a nofollow tag to all external links automatically in Blogger, and your blog's outbound links stay under your control. If you also want your post URLs to look clean, read my guide on how to optimize permalinks in Blogger.

For more Blogger tips and plugins, subscribe and get the latest posts in your inbox.