WordPress rel=”nofollow ugc” attribute

WordPress rel=”nofollow ugc” attribute
WordPress rel=”nofollow ugc” attribute

Learn how to use WordPress's wp_rel_ugc() function to automatically add rel="nofollow ugc" to user-generated content (UGC) links, improving your site's SEO and protecting it from spammy links.

If you run a site that lets people leave comments, post in a forum, or drop a guest article, you’ve inherited a small SEO problem: you don’t control the links those people add. Some are fine. Some are spam. Search engines need a way to tell the two apart from the links you actually vouch for.

WordPress 5.3 shipped a helper for exactly this: wp_rel_ugc(). It takes an anchor tag and adds rel="nofollow ugc" so the link gets flagged as user-contributed. Let’s walk through what it does and when you’d reach for it.

What the ugc value actually means

UGC is short for User Generated Content. It’s a rel attribute value Google recommends for links that came from your users, not from you: comments, forum posts, that kind of thing.

For years, nofollow was the only tool for this. Then on September 10, 2019, Google announced two more values, ugc and sponsored, to describe links more precisely. ugc says “a user added this.” sponsored says “this is an ad or paid placement.” You can stack them with nofollow, which is why rel="nofollow ugc" is a valid combination.

Here’s the part most older tutorials get wrong, so read it twice. Since March 1, 2020, Google treats nofollow, ugc, and sponsored as hints, not hard directives. They no longer guarantee a link won’t be followed or counted. Google uses them as signals, alongside everything else it knows, to decide how much to trust a link. In practice it still tends to ignore these links for ranking, but “we promise never to follow this” is not what the attribute means anymore.

For the source, see Google’s official announcement.

Why the function is worth knowing

Before 5.3, if you wanted user links flagged you were bolting nofollow on by hand. wp_rel_ugc() does the marking for you and gets the combination right.

Good news: for standard comments you usually don’t need to call it at all. Since 5.3, WordPress already applies rel="nofollow ugc" to comment links and comment author URLs by default. The function is for the cases WordPress doesn’t cover automatically, like a custom forum, a directory, or a guest-post workflow where the links live somewhere other than the comment stream.

How wp_rel_ugc() works

It’s a small function. You hand it a string containing an anchor tag; it hands back the same tag with nofollow ugc added to the rel attribute. If the link already has other rel values like noopener or noreferrer, those stay put.

  • Input: a string containing an anchor tag.
  • Processing: it reads the existing rel values and adds nofollow ugc without dropping what’s there.
  • Output: the same anchor tag, now carrying nofollow ugc.

A basic example

$url = 'user forum comment';
$ugc_url = wp_rel_ugc( $url );
echo $ugc_url;
// Output: user forum comment

You pass in a plain anchor tag pointing at a user comment. The function returns it with nofollow ugc attached, so Google can see the link is user-contributed.

Keeping existing rel values

If the link already carries a rel value, the function adds to it instead of overwriting:

$url = 'user profile';
$ugc_url = wp_rel_ugc( $url );
echo $ugc_url;
// Output: user profile

noopener survives, and nofollow ugc joins it. Nothing gets clobbered.

When you’d use it

  • Custom comment output: if you render comment links yourself instead of using core’s default output.
  • Forums: flagging links inside user-generated forum posts.
  • Guest posts: marking links an outside contributor added, since you can’t always stand behind them.
The short version

wp_rel_ugc() is a small, useful helper for marking user-contributed links as user-contributed. Core already does this for standard comments, so reach for the function when you’re handling links outside that flow. And keep the expectations honest: since March 2020 these rel values are hints Google weighs, not switches that force its hand. Mark your links correctly and let Google do the rest.

Next: WooCommerce vs Shopify

4 thoughts on “WordPress rel=”nofollow ugc” attribute”

  1. At this time it looks like BlogEngine is the preferred blogging platform available right now.

    (from what I’ve read) Is that what you’re using on your blog?

  2. vertigo lamp replica

    Hi there, I wish for to subscribe for this webpage to obtain newest updates, thus where
    can i do it please assist.

Leave a Comment

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


Scroll to Top