In short
The rel="ugc" attribute (User Generated Content) signals that a link was posted by a user and not by your editorial team: comment, forum post, review, member profile. This check only concerns sites that let their visitors post links. Once it is done, these links carry ugc, often combined with nofollow, and your own editorial links stay unchanged.
Why it matters
An editorial link is a form of recommendation: your site vouches for the linked page. A link left by a visitor in a comment does not reflect your judgment. Google therefore recommends marking user-generated links, such as those in comments and forums, with the ugc value.
Three concrete reasons:
- Discourage spam: comment sections and forums attract bots that drop links for ranking purposes. Google lists forum comments with optimized links among the examples of link spam. Qualified links make your site less attractive to them.
- Protect your site: a site whose unqualified outgoing links point massively to dubious sites risks an “Unnatural links from your site” manual action.
- Be honest with search engines:
ugcdescribes the nature of the link more precisely thannofollow.
Since 2019, Google has treated ugc, sponsored and nofollow as hints. It also allows an exception: you can remove ugc from the links of members who have been contributing constructively for a long time. The attribute is therefore applied “if relevant”: it depends on how much you trust each contributor.
What it improves
- Spam Less appeal for bots that post links, without stopping them on its own (anti-spam protection is still needed).
- Risk Your site is not associated with links you did not choose.
- Community quality The exception for trusted contributors rewards good members.
- Rankings No direct effect on your pages. Qualified outgoing links neither gain nor lose you positions.
- Generative engines No documented effect of the attribute.
How to check
- List the areas where a visitor can post a link: comments, the “website” field in comments, forum, product reviews, Q&A, public profiles, open-registration directory, guestbook.
- Check the HTML of a page in each area that contains a link posted by a visitor:
curl -s https://example.com/blog/article-avec-commentaires/ \
| grep -o -i -E '<a [^>]*href="https?://[^"]*"[^>]*>' \
| grep -v "example.com" | grep -v -i -E 'ugc|nofollow|sponsored'
No result in the comments area is the expected outcome. Any remaining lines must correspond to your editorial links, not to visitors' links.
- In the browser, inspect a comment link (right-click, “Inspect”) and read its
relattribute. - In Screaming Frog, export all outlinks and filter on forum or comment pages: the
relattribute column must containugcornofollow.
How to implement
Before you start
Recommended value: rel="ugc nofollow". ugc describes the nature of the link; nofollow, long accepted by all search engines, serves as a fallback for any that do not recognize ugc. Google accepts several values separated by spaces.
| Area | Value |
|---|---|
| Link in a comment, a forum post, a review | ugc nofollow |
| Comment author's “website” link | ugc nofollow |
| Link in a public member profile | ugc nofollow |
| Link posted by a long-standing trusted member | Optional attribute (exception allowed by Google) |
| Paid link posted by a user (ad, paid listing) | sponsored ugc |
| Link added by your team in a moderation reply | No attribute |
Fighting spam: the attribute is not enough. Turn on moderation for first comments and an anti-spam filter, and remove the “website” field from the form if you have no use for it. If links appear on pages nobody has moderated, see monitor hacking and content and link injections (opens in a new tab).
WordPress
Versions WordPress 6.2 to 7.1; bbPress 2.6.
There is nothing to do for native comments since WordPress 5.3:
- links written in the text of a comment receive
rel="nofollow ugc"when saved (wp_rel_ugcfilter onpre_comment_content); - since WordPress 6.2, URLs automatically turned into links on display receive
nofollow(if external) andugc(make_clickable_relfilter); - the link to the author's website receives
ugc, plusexternal nofollowif it is external.
Comments saved before version 5.3 keep rel="nofollow", which is still acceptable.
bbPress adds nofollow and then ugc to links in topics and replies by default. For another forum, review or Q&A plugin, check the HTML with the command from “How to check”.
Exception for trusted contributors (WordPress 6.2 or later), in a small plugin or a child theme's functions.php: remove ugc and nofollow from the author link of registered users who have at least the Contributor role.
<?php
add_filter('comment_author_link_rel', function (array $relParts, WP_Comment $comment): array {
if (! $comment->user_id) {
return $relParts;
}
if (! user_can((int) $comment->user_id, 'edit_posts')) {
return $relParts;
}
return array_values(array_diff($relParts, ['ugc', 'nofollow']));
}, 10, 2);
Remove the “website” field from the comment form, often the main target of bots:
<?php
add_filter('comment_form_default_fields', function (array $fields): array {
unset($fields['url']);
return $fields;
});
Clear the page cache after making changes.
Drupal
Versions Drupal 10 and 11.
In Configuration > Content authoring > Text formats and editors (/admin/config/content/formats), edit the format used for comments and anonymous users (often “Restricted HTML” or “Basic HTML”). In the “Limit allowed HTML tags and correct faulty HTML” filter, check Add rel="nofollow" to all links.
Drupal then adds nofollow, not ugc, and replaces any existing rel. This is compliant: nofollow is still accepted for these links. Do not apply this format to your editorial team's content, or all your editorial links will become nofollow. Clear the caches with drush cr.
Discourse
Versions Discourse, site settings as of November 2026, hosted or self-hosted.
By default, Discourse adds rel="noopener nofollow ugc" to external links posted by members. The settings are in the admin area, under site settings:
add rel nofollow to user content: turns on link qualification (enabled by default);exclude rel nofollow domains: exempted domains, for example your own site or your company's;tl3 links no follow: decides whether links from trust level 3 members keep the qualification. Read its description in your version before changing it; it is the equivalent of Google's exception for trusted contributors.
Shopify
Versions Shopify admin, all plans, November 2026.
Blog comments are set per blog in Content > Blog posts > Manage blogs, under “Comments”: disabled, allowed pending moderation, or allowed and automatically published. Choose moderation. Shopify does not document how links in comments are handled: check on your store, with the command from “How to check”, whether the URLs entered become clickable links.
Product reviews and Q&A go through apps: check the HTML they produce and, if their links have no attribute, contact the app developer or turn off links in its settings.
Laravel
Versions Laravel 11 to 13, with league/commonmark 2.x.
If user messages are written in Markdown and converted with Str::markdown() (league/commonmark), add an extension that qualifies all external links. league/commonmark's External Links extension handles nofollow but not ugc: write your own.
<?php
namespace App\Markdown;
use League\CommonMark\Environment\EnvironmentBuilderInterface;
use League\CommonMark\Event\DocumentParsedEvent;
use League\CommonMark\Extension\CommonMark\Node\Inline\Link;
use League\CommonMark\Extension\ExtensionInterface;
class UserContentLinksExtension implements ExtensionInterface
{
public function register(EnvironmentBuilderInterface $environment): void
{
$environment->addEventListener(DocumentParsedEvent::class, function (DocumentParsedEvent $event): void {
$siteHost = parse_url(config('app.url'), PHP_URL_HOST);
foreach ($event->getDocument()->iterator() as $node) {
if (! $node instanceof Link) {
continue;
}
$host = parse_url($node->getUrl(), PHP_URL_HOST);
if (! is_string($host) || $host === $siteHost) {
continue;
}
$node->data->append('attributes/rel', 'ugc');
$node->data->append('attributes/rel', 'nofollow');
}
});
}
}
Converting a comment, with raw HTML stripped and unsafe links rejected:
use App\Markdown\UserContentLinksExtension;
use Illuminate\Support\Str;
$html = Str::markdown($comment->body, [
'html_input' => 'strip',
'allow_unsafe_links' => false,
], [new UserContentLinksExtension()]);
For the trusted contributor exception, only add the extension if the author does not yet have that status ($comment->user->is_trusted, for example). If comments are displayed as plain text with {{ $comment->body }}, no link is clickable and there is nothing to do.
Next.js
Versions Next.js 15 and 16 (App Router and Pages Router); react-markdown 9 and 10, rehype-sanitize 6, rehype-external-links 3.
To display user-written Markdown with react-markdown, combine rehype-sanitize and rehype-external-links:
// components/UserContent.tsx
import Markdown from 'react-markdown';
import rehypeExternalLinks from 'rehype-external-links';
import rehypeSanitize from 'rehype-sanitize';
export function UserContent({ body }: { body: string }) {
return (
<Markdown
rehypePlugins={[
rehypeSanitize,
[rehypeExternalLinks, { rel: ['ugc', 'nofollow'] }],
]}
>
{body}
</Markdown>
);
}
rehype-external-links changes all absolute http and https links, including those pointing to your own domain; add a test option if you want to exclude them. Its documentation recommends not using it on user content without rehype-sanitize. For links built in JSX (a member's profile link), write rel="ugc nofollow" directly on the <a> tag.
Common mistakes
- Applying
nofollowto the whole site to “be safe”: your editorial links to your sources lose their meaning. - Forgetting secondary areas: member profiles, forum signatures, product reviews, open-registration directory pages.
- Relying on the attribute to stop spam: bots post anyway. Moderation and anti-spam protection remain essential.
- Leaving qualified spam links online:
ugclimits the risk, but a page full of links to dubious sites harms readers. Delete them. - Removing the attribute for every registered member: Google's exception targets long-standing constructive contributors, not an account created the day before.
- An HTML sanitizer that strips
relafter your processing: check the final HTML, not the configuration.
Frequently asked questions
Should you use rel="ugc" or rel="nofollow" for comments?
Google recommends rel="ugc" for links posted by users, such as comments and forum posts, and also accepts nofollow. The most common approach is to combine the two, rel="ugc nofollow", which WordPress has done by default since version 5.3. There is no need to change older comment links already qualified with nofollow alone.
Does Google ignore rel="ugc" links?
Google treats rel="ugc" as a hint rather than a strict directive: it takes it into account when deciding which links to consider in its ranking. Links marked this way are generally not followed, but the linked page may be crawled if Google discovers it another way, for example through a sitemap or a link from another site. The attribute does not pass your trust to the linked page.
Can you remove rel="ugc" for trusted forum members?
Yes, Google explicitly allows it for members who have been contributing constructively for a long time. Define an objective criterion, such as account age, the number of approved posts or a role assigned by moderators, and apply it automatically. Discourse offers a setting tied to trust levels, and WordPress lets you do it with the comment_author_link_rel filter.
Is rel="ugc" enough to block comment spam?
No, rel="ugc" makes links less attractive for ranking but does not stop bots from posting. Combine it with moderation of first posts, an anti-spam filter and removal of the “website” field from the form if you do not need it. Also delete spam comments that have already been published: a qualified link is still a useless link for your readers.
Resources
- Google Search Central: qualify your outbound linksdevelopers.google.com
- Google Search Central Blog: evolving “nofollow”, new ways to identify the nature of links (2019)developers.google.com
- WordPress: wp_rel_ugc function and get_comment_author_linkdeveloper.wordpress.org
- Shopify Help Center: managing blog commentshelp.shopify.com
- league/commonmark: External Links extensioncommonmark.thephpleague.com
- rehype-external-links and rehype-sanitizegithub.com
Updated on
Topic checklist (PDF)