How to Add Nofollow Links in WordPress (Menus, Posts and Block Themes)

To make a WordPress menu link nofollow, go to Appearance > Menus, open Screen Options, tick Link Relationship (XFN), then type nofollow in that field on the menu item and save. In a block theme, select the link in your Navigation block and type nofollow in its Rel attribute field instead. For a link inside a post, open the link’s settings and turn on Mark as nofollow.

Below are the steps for all three, checked in WordPress 7.1, plus when you should use nofollow at all. Google’s rules have changed since this was a blanket recommendation for every outside link.

Key Takeaways
  • In a classic menu, the nofollow field is hidden until you tick Link Relationship (XFN) under Screen Options on the Menus screen.
  • In a block theme, select the link in the Navigation block and type nofollow in its Rel attribute field.
  • For a link inside a post or page, open the link’s settings and turn on Mark as nofollow.
  • Google asks for sponsored on paid and affiliate links and ugc on user content. Use nofollow when neither fits and you do not want to vouch for the site.
  • WordPress already adds rel="nofollow ugc" to links in comments, and you should not nofollow links to your own pages.

Video tutorial

Here is a quick video showing the classic menu method.

How to add nofollow to a classic WordPress menu

If your theme uses Appearance > Menus, the option is built in but hidden by default:

  1. Go to Appearance > Menus and select the menu you want to edit.
  2. Click Screen Options at the top right of the screen.
  3. Tick Link Relationship (XFN). This adds a new field to every menu item.
  4. Click the arrow on the menu item you want to change, and type nofollow in the Link Relationship (XFN) field.
  5. Click Save Menu.
Screen Options button in the WordPress menu editor
Screen Options, at the top right of the Menus screen
Link Relationship XFN checkbox in WordPress Screen Options
Tick Link Relationship (XFN) to show the field
Adding nofollow to the Link Relationship XFN field in a WordPress menu item
Type nofollow into the menu item’s Link Relationship (XFN) field

The field takes any rel values, separated by spaces, so you can enter nofollow sponsored for a paid link. The same Screen Options panel has a Link Target box, which adds an “Open link in a new tab” checkbox to each item. Whether those links still need rel="noopener" is covered in our guide to rel=”noopener” in WordPress.

Block themes such as Twenty Twenty-Five do not use the Menus screen. Their menus are Navigation blocks, edited in the Site Editor:

  1. Go to Appearance > Editor and open the template or header that contains your menu.
  2. Click the menu, then select the individual link you want to change.
  3. In the block settings sidebar on the right, type nofollow in the Rel attribute field.
  4. Click Save.

The Rel attribute field is shown by default. If you do not see it, open the three-dot menu at the top of the Settings panel and switch it on.

How to nofollow a link in a post or page

For links in your content, the block editor has a switch for it:

  1. Click the link in the editor, then click the edit (pencil) icon in the link popup.
  2. Open the Advanced settings.
  3. Turn on Mark as nofollow, then save the link.

To add sponsored or ugc instead, select the block, choose Edit as HTML from its options menu, and change the link’s rel value by hand.

When to use nofollow, sponsored or ugc

Nofollow used to be the default advice for every link that left your site. Google now asks for more specific values, according to its guide to qualifying outbound links:

ValueUse it for
rel="sponsored"Ads, paid placements and affiliate links.
rel="ugc"Links in user-generated content, such as comments and forum posts.
rel="nofollow"Links you do not want to vouch for when neither of the above applies.
Link rel values Google recognizes. You can combine them, for example rel=”nofollow sponsored”.

An ordinary editorial link to a site you trust needs no rel value at all, and adding nofollow to every outside link does nothing for you. Two more rules save you work:

  • WordPress already handles comments. Since version 5.3 it adds rel="nofollow ugc" to every link in a comment when the comment is saved.
  • Do not nofollow links to your own pages. Google recommends robots.txt, not nofollow, for keeping crawlers away from parts of your site.

For a deeper explanation of the three values, see Ryan Robinson’s guide to nofollow, sponsored and ugc links.

How to check that a link is nofollow

View your page’s source (Ctrl+U, or Cmd+Option+U on a Mac), or right-click the link and choose Inspect, and look for rel="nofollow" on the link:

rel nofollow attribute shown in the page source code
A nofollow menu link in the page source

If it is missing after you saved, clear your page cache and check again.

Frequently asked questions

How do I add a nofollow link in WordPress?

In the block editor, click the link, open its Advanced settings and turn on Mark as nofollow. For a classic menu item, enable Link Relationship (XFN) in Screen Options and type nofollow in the field. For a block theme menu, type nofollow in the link’s Rel attribute field.

Should all external links be nofollow?

No. Google asks you to mark paid and affiliate links as sponsored and user content as ugc, and to use nofollow only for links you do not want to vouch for. Normal editorial links to sites you trust need no rel value.

How do I make an affiliate link sponsored in WordPress?

In a classic menu, type sponsored (or nofollow sponsored) in the Link Relationship (XFN) field. In a post, use Edit as HTML on the block and set rel=”sponsored” on the link, since the link popup only has a nofollow switch.

Are WordPress comment links nofollow?

Yes. Since WordPress 5.3, links in comments are saved with rel=”nofollow ugc” automatically, so you do not need a plugin for that.

What is Link Relationship (XFN) in WordPress menus?

It is the menu item field that sets a link’s rel attribute. XFN stands for XHTML Friends Network, an old way of describing relationships between sites, but the field accepts any rel value, including nofollow and sponsored.

Picture of Andy Feliciotti

Andy Feliciotti

Andy has been a full time WordPress developer for over 15 years. Through his years of experience has built 100s of sites and learned plenty of tricks along the way. Found this article helpful? Buy Me A Coffee

3 Responses

Leave a Reply

Your email address will not be published. Required fields are marked *

WordPress Tips Monthly
Get the latest from SmartWP to your inbox.