How to Add a Dofollow or Nofollow Link in HTML (With Code Examples)

·

How to Add a Dofollow or Nofollow Link in HTML (With Code Examples)

A dofollow link is a plain <a href="..."> tag with no rel attribute at all. A nofollow link is the same tag with rel="nofollow" added. Paid links get rel="sponsored", and links from comments or forums get rel="ugc". All four can combine with other rel values, like noopener, inside the same quotes. Here is every pattern side by side:

<!-- Dofollow: the default. No rel attribute at all. -->
<a href="https://example.com">Anchor text</a>

<!-- Nofollow -->
<a href="https://example.com" rel="nofollow">Anchor text</a>

<!-- Sponsored: paid placements, ads, affiliate links -->
<a href="https://example.com" rel="sponsored">Anchor text</a>

<!-- User-generated content: comments, forum posts -->
<a href="https://example.com" rel="ugc">Anchor text</a>

The rest of this guide covers the syntax rules behind these four patterns, how to combine values on one link, and the mistakes that quietly break them. For the strategic side, when each value is the right call and what changed under Google’s 2019 policy update, see the complete guide to link attributes.

The Four rel Values You Can Add to an HTML Link

rel valueHTMLWhat it tells Google
(none)<a href="https://example.com">Text</a>Full editorial endorsement. May pass a ranking signal.
nofollow<a href="https://example.com" rel="nofollow">Text</a>Don’t associate my site with, or crawl from, this link.
sponsored<a href="https://example.com" rel="sponsored">Text</a>This link exists because of a paid or compensated arrangement.
ugc<a href="https://example.com" rel="ugc">Text</a>This link came from user-submitted content, not the site owner.

Google’s own documentation defines each value directly. Use sponsored to “mark links that are advertisements or paid placements,” use ugc for links such as “comments and forum posts,” and reach for nofollow “when other values don’t apply, and you’d rather Google not associate your site with, or crawl the linked page from, your site.” All three work as hints, not hard rules: a marked link will generally not be followed, but the same destination can still get crawled through a sitemap or a link somewhere else.

Writing a Nofollow Link: The Exact Code

A nofollow link needs exactly one addition to a standard anchor tag:

<a href="https://example.com/page" rel="nofollow">Anchor text</a>

Two syntax details cause most of the errors people run into. First, quotes: always wrap the value in quotes. A single unquoted value like rel=nofollow will often still parse in a browser, but it breaks the moment you add a second value, since an unquoted space ends the attribute early. Second, capitalization: rel keywords are “always ASCII case-insensitive,” per the HTML specification, so rel="NoFollow" and rel="nofollow" are read identically by browsers and crawlers. There’s no functional reason to capitalize it; lowercase is the convention because it’s what every export and tool uses.

Marking Paid and User-Generated Links with rel=”sponsored” and rel=”ugc”

Paid placements and user-submitted links get their own values instead of a blanket nofollow:

<!-- A paid placement, ad, or affiliate link -->
<a href="https://example.com/product" rel="sponsored">Anchor text</a>

<!-- A link inside a comment, review, or forum post -->
<a href="https://example.com/site" rel="ugc">Anchor text</a>

If you run a WordPress site, you likely already have ugc links you didn’t write by hand. “Starting in WordPress 5.3, links in comments and comment author URLs will use the rel=”nofollow ugc” attribute by default.” That’s a useful baseline, but it also means a spam comment with a promotional link still qualifies for ugc correctly; the value describes who created the link, not whether the link is legitimate.

For a full breakdown of when to reach for sponsored versus ugc versus a plain nofollow, including affiliate-link edge cases, see rel=sponsored and rel=ugc explained.

Combining rel Values on the Same Link

Multiple rel values live in the same attribute, separated by spaces:

<a href="https://example.com" rel="sponsored nofollow">Anchor text</a>

The most common real-world combination pairs a link attribute with a security attribute. Any link using target="_blank" is worth pairing with rel="noopener", which stops the new tab from getting a script reference back to your page through window.opener. Modern browsers apply that protection automatically now: MDN notes that “setting target=”_blank” … implicitly provides the same rel behavior as setting rel=”noopener”.” Writing it explicitly still matters for older browsers and for anyone reading the HTML later. Add noreferrer on top and the outgoing Referer header gets stripped too:

<a href="https://example.com" rel="nofollow noopener noreferrer" target="_blank">Anchor text</a>

One line, three separate protections: the link carries no ranking endorsement, the new tab can’t reach back into your page’s window object, and the destination never learns which page sent the click.

Mistakes That Silently Break the rel Attribute

A handful of errors show up constantly in code review and backlink audits:

  • Writing rel="dofollow". There’s no such attribute. “Despite being widely used, ‘dofollow’ is not a correct term because there’s no ‘dofollow’ link attribute.” Adding the word does nothing; a dofollow link is created by leaving rel off entirely, not by naming it.
  • Missing quotes on a multi-value rel. rel=nofollow noopener without quotes tells the parser the attribute value is nofollow and that noopener is a second, invalid attribute floating on its own. Always wrap the full value: rel="nofollow noopener".
  • Confusing the link-level attribute with a page-level directive. rel="nofollow" on an <a> tag only affects that one link. It has no effect on whether the destination page itself gets indexed; that’s controlled by a noindex meta tag or header on the page, a separate mechanism entirely. See nofollow vs noindex for the full mechanics.
  • Assuming the HTML you wrote is the HTML that shipped. A guest post editor, a directory submission form, or a CMS filter can strip or add rel values after you submit them. The only way to know what actually rendered is to check the live page, not your draft.

Checking one link means right-clicking it in a browser, choosing Inspect, and reading the rel value straight off the rendered <a> tag. Checking dozens or hundreds of links you’ve built across guest posts, directories, and partner pages one by one doesn’t scale that way. That’s the kind of check BacklinkTower runs in bulk, reading the live rel attribute off every URL in an export so you can see which links still carry the code you originally submitted and which ones changed after the fact.

Frequently Asked Questions

Do I need quotes around a rel attribute value?

Always use quotes, even for a single value like rel="nofollow". An unquoted single value often still parses in a browser, but it’s invalid HTML and breaks as soon as you add a second value, since an unquoted space ends the attribute early.

Can I write rel=”dofollow” to force a link to be followed?

No. There is no dofollow attribute in HTML or in Google’s documentation. A dofollow link is simply an anchor tag with no rel attribute at all; adding the word “dofollow” as a value does nothing.

Does capitalization matter, like rel=”NoFollow” versus rel=”nofollow”?

No. Rel keywords are ASCII case-insensitive under the HTML specification, so rel="NOFOLLOW", rel="NoFollow", and rel="nofollow" are all read identically by browsers and search engines. Lowercase is simply the universal convention.

Should I separate multiple rel values with a space or a comma?

Use a space. Google’s documentation accepts either a space- or comma-separated list, but the HTML specification defines rel as a space-separated set of tokens, so rel="nofollow noopener" is the form every browser and parser expects.

Do I need rel=”noopener” on every external link, even without target=”_blank”?

No. noopener only matters on links that open in a new tab or window through target="_blank". A link that opens in the same tab has no window.opener exposure to protect against.

Will WordPress add a rel attribute to my links automatically?

Yes, in one specific case. Comment links and comment author URLs have used rel="nofollow ugc" by default since WordPress 5.3. Links you add yourself inside a post or page body get no automatic rel value; you have to add those.

Does rel=”nofollow” on a link stop the destination page from being indexed?

No. rel="nofollow" is a link-level attribute that only affects how that one link is treated. Whether a page appears in Google’s index is controlled separately, by a noindex meta tag or HTTP header on that page.


Get Link Building Tips

Weekly strategies and insights delivered to your inbox. No spam, unsubscribe anytime.

Comments

Leave a Reply

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