3 easy ways to create nofollow links in WordPress posts and menus

When and how to use nofollow links in WordPress

Website development illustration

Do you need to use nofollow links in your website or blog posts? What are they? Why do you need them? How do you create them? These questions are answered here: Learn to use nofollow links.

You may have heard of nofollow links and wondered whether you should be using them on your website or blog. You might not even know what they are. You probably should be using some nofollow links, but it depends on several factors and sometimes you need them and sometimes you don’t.

WordPress does not give any advice on the subject and almost no features to help you use them. This is odd considering that there are very good reasons for using them and possibly penalties if you don’t.

What a normal link looks like

We all know what a link is and does, it is text on a web page, usually highlighted in some way, that takes you to another web page on the same website or a completely different one. You cannot tell a normal web link, sometimes called dofollow, from a nofollow link. They look identical. However, the HTML code that makes up the page is different.

If you were to look at the HTML code of a normal web link, it would look like this:

<a href=”https://www.yahoo.com”>Yahoo!</a>

What a nofollow link looks like

A nofollow link on a web page looks identical to a normal one, but there is a difference in the HTML code and it looks like this:

<a rel=”nofollow” href=”https://www.yahoo.com”>Yahoo!</a>

Notice the addition of rel=”nofollow” to the code. It can come before the href=”” link or after it and it doesn’t make much difference, but WordPress likes it before.

Links boost search rankings

Google scans web posts for links and when a big, important, authoritative website links to another website, it passes on some of its authority, sometimes called link juice. The link is an indicator to Google that the site linked to is a good one. This raises its position in search results, so it appears nearer to the first page of search results and nearer to the top of the first page.

Backlinks, links from other websites to your own, are therefore valuable and help you rise to the first page of search results. It is not the only factor that affects your search position and there are said to be around 200, but it is an important one.

The more backlinks you have, the higher you appear in search results, which is great, but it tempts some people to try and cheat to rank higher.

When to use nofollow

Someone could pay you to post an article on your website in order to get a backlink. They could provide you with free goods or services, so you write about them and provide a backlink. They could provide free holidays or travel, days out, meals, and so on, in return for you including a backlink in a web article. An article may be sponsored.

These backlinks are not natural ones and if you receive any form of compensation for a link in an article, you must make it a nofollow link.

Affiliate links fall into this category too and one way or another, you receive money, goods or services from them. Affiliate links must be nofollow.

We don’t want websites appearing on page one of Google search results simply because they paid people to insert backlinks in articles. We want search results to show authority websites and articles.

Natural web links to articles and sites that are relevant to the content people are reading should be normal links. Links where you receive some sort of compensation should be nofollow.

Does Google follow nofollow links?

Nofollow sounds like it is an instruction not to follow a link to another website. It is not. Links are links and Google will follow them if it wants to.

Nofollow tells Google not to pass any authority or ranking boost to the linked website because the link was paid for or the author received some sort of compensation.

1 Create nofollow links with WordPress block editor

For this guide I will use the Gutenberg block editor in the latest version of WordPress. Although some people still use the classic post editor, sooner or later it will be discontinued and you will have to use the block editor, so you may as well get used to it.

Let’s assume you are writing an article in the post editor and you want to create a link to a website and make it nofollow. Select the text and then click the Link button in the toolbar.

Creating a link in a WordPress post using the block editor

A little box opens under the selected text and you can then enter the URL of the website you want to link to. Click the Apply button to finish.

Creating a link in a WordPress post using the block editor

This has created a normal link that will be followed and authority and link juice will be passed on to the website. If you received any compensation in return for the link like money, gifts, freebies and so on, it must be made nofollow. Click the link to select it and then click the three dots icon to see more options.

Creating a link in a WordPress post using the block editor

As we saw earlier, normal and nofollow links look the same, but the HTML code is different. Click the three dots and select Edit as HTML from the menu that appears.

Edit a WordPress block as HTML

The WordPress post editor shows the HTML code for this block (the paragraph of text). Look for the <a href=”…. that defines the link and insert rel=”nofollow” like this:

Edit a block as HTML in the WordPress editor

This is all one line by the way. Be very careful when editing HTML code because a simple typing slip can cause problems with text, links or images failing to appear. Check it and then click the three dots button above the block and select Edit visually.

Edit a block in the visual editor in WorPress

That’s it. The HTML code disappears and the text and link appears as normal in the editor. It looks the same as it did before, but it is now a nofollow link.

A nofollow link in the WordPress post editor

2 Use the WordPress code editor for nofollow

It is a multi-step process and a bit fiddly to change a normal link to a nofollow one, so here is an alternative method. This is best when there are many links in a post that need to be set to nofollow.

When editing a post in WordPress, click the three dots in the top right hand corner to show a menu and in the Editor section is Visual Editor and Code Editor. Posts are created in the Visual Editor, but you can switch to the Code Editor to see the HTML code that makes up the page.

Switch editing mode in the WordPress post editor

Look for the links on the page, they begin <a href=”… and insert the rel=”nofollow” text. Posts can be long and complicated, and the links can be hard to spot, so press Ctrl+F (PC) or Cmd+F (Mac) to open the browser’s search box and enter ‘<a’ or ‘href’ into it to find the first link. Use the arrow buttons to jump to the next link and the next. You can copy the nofollow text and then simply paste it each time – jump to the next link, paste, jump to the next link, paste and so on.

Edit the code in the WordPress post editor to add a nofollow link

When you have finished adding nofollow links, use the menu in the top right corner of the page to switch back to the visual editor. Don’t make mistakes editing code. They can mess up the page.

3 Make WordPress menus nofollow

WordPress does not provide any features for creating nofollow links in the post editor, which is where they are used most, but it does provide a simple way to make links nofollow in menus, where they are used the least. That is a bit upside down, although without this feature it would be impossible to nofollow menus.

In the WordPress sidebar, go to Appearance > Menus. Click Screen Options at the top of the page to display this list of options and tick the checkbox Link Relationship (XFN). Close Screen Options afterwards.

Customise the menu editing screen in WordPress

Create menus in the usual way by adding pages, categories, custom links and so on. The menu structure is shown and if you expand a menu item using the up/down arrow on the right, you will see a Link Relationship (XFN) box. Simply type nofollow into the box. Don’t forget to save the menu after making changes to it.

Make WordPress menus nofollow links

It is hard to think of cases where you would want to nofollow a menu, but it is easy to do if you ever need it.


What's next?

Affiliate links

About Roland Waddilove 278 Articles
Roland Waddilove has been writing about computers, software and gadgets for many years. He has been editor of several computer magazines, but these days is a freelance writer.