One question that I was struggling with a lot when I started using WordPress for the first time, is how to add link relations to a menu item. One of the most well known link relations is “nofollow”. In this article I’ll show you how to add a link relation to a WordPress menu item.
What is “rel=nofollow”?
A “nofollow” link is a link that has rel=”nofollow” applied to it in HTML. Below code snippet shows the difference between a “normal” link and a “nofollow” link:
<!-- Normal Link: --> <a href="https://wouterpostma.com/">My Link</a> <!-- Nofollow Link: --> <a href="https://wouterpostma.com/" rel="nofollow">My Nofollow Link</a>
“Rel” stands for relation. When applied to a link, this means that it is used to set the link relation.
By adding the nofollow tag to a link, you can tell search engines like Google to ignore that link. Search engines “crawl” the web by going to pages they know and following the links on those pages. By adding ‘nofollow’ you’re basically telling them not to follow that link. Nofollow links do not pass any PageRank or any other type of authority.
So called “backlinks” are one of the main ways for Google to determine your site’s authority. If many other sites link to you, your authority will increase. The value of those links is higher when they come from websites with a high authority and a high relevance with your page.
For instance, if you own an e-commerce store that sells bicycles, a backlink from a New York Times article about bicycles will be of more value to your site than a backlink from – for example – this site. If that same link is a nofollow link, none of that value would be passed on to your site.
There are many reasons to use nofollow links. A classic example is when you leave a comment on one of my blog posts: you will have the option to enter your website. The name shown above the comment will contain a link to the URL you entered.
To prevent users from commenting just to get a “backlink”, the “nofollow” relation is automatically added by WordPress. Also, a user may type links in the comments to gambling or other “adult only” types of sites that I do not want my website to be associated with. By adding nofollow to those links, my site will not be penalized by Google for linking to those sites.
You will see the same logic on many forums. When users post a link on a forum, those will usually have the nofollow attribute.
Link relations are a way to describe the type of link and/or the relationship between your source and the destination of the link. A simple example is the rel=”me” when linking from one page about you to another page about you, for instance your profile on a third party website.
<a href="http://twitter.com/wdpostma" rel="me">Follow me on Twitter</a>
A link relation is a descriptive attribute attached to a hyperlink in order to define the type of the link, or the relationship between the source and destination resources. The attribute can be used by automated systems, or can be presented to a user in a different way.
A full overview of possible link relations can be found here.
Time needed: 5 minutes.
How to add nofollow to a WordPress menu item
In a WordPress menu, by default all links are “normal” links, meaning search engines will follow them. If you do want to add the nofollow relation to one of the links in your WordPress menu, you can follow (no pun intended) the steps below.
- Open screen options
First, go to Appearance > Menus to edit the menu that you want to include a nofollow link in. Once your link is in your menu, click “Screen options” on the top of the screen:
- Check the “Link Relationship (XFN)” box
In the Screen Options, select the “Link Relation” box:
- Open the menu item and add “nofollow”
Now, open the menu item and add the “nofollow” tag to the Link Relation box.
You can use this field for any link relation you may want to add. Leave it empty if you do not want to add any link relation.
- Click “Save Menu” to save your changes
Now, click the “Save Menu” button and your changes will be saved.