DEV Community

Kausar Ansari
Kausar Ansari

Posted on

My rich-text editor was quietly nofollowing my own internal links

I run a small publishing platform built with Next.js, with a TipTap editor where authors write their articles. This week I found a bug that wasn't really a bug: the editor was doing exactly what we'd configured it to do.

What I found

I was auditing why newer articles were slow to get indexed. Rendering was fine, canonicals were fine, and the sitemap was fine. Then I looked at the saved HTML of an article and saw this on a link to another article on the same site:

<a href="/some-author/related-article" target="_blank" rel="nofollow">
Enter fullscreen mode Exit fullscreen mode

Every link inserted through the editor got rel="nofollow" and target="_blank", internal ones included.

Why it happened

TipTap's Link extension accepts default HTMLAttributes, and we had set:

Link.configure({
  HTMLAttributes: { target: '_blank', rel: 'nofollow' },
})
Enter fullscreen mode Exit fullscreen mode

That's a sensible default for outbound links on a site with user-generated content. Applied to internal links, it tells search engines not to follow your own navigation, and it opens every related article in a new tab, which is annoying for readers.

The fix

Decide the attributes per link based on the URL, instead of using one blanket default. You can do it when the HTML is rendered, or in the editor when a link is set:

function linkAttrs(href) {
  const internal = href.startsWith('/') || href.startsWith('https://yourdomain.com');
  return internal
    ? { target: null, rel: null }
    : { target: '_blank', rel: 'nofollow noopener' };
}
Enter fullscreen mode Exit fullscreen mode

Then run a one-off migration over existing content to strip nofollow and target="_blank" from internal links.

The bigger lesson

While I was at it, I checked the published articles, and almost none of them had any in-content links to other articles. Authors write in isolation, so each post is linked only from the homepage feed and paginated archives. Once a post drops off page one, crawlers barely reach it.

So, two takeaways if you run any CMS with an editor:

  1. Inspect the published HTML of a few posts. Don't trust the editor preview.
  2. Make internal linking part of the publishing flow, not an afterthought.

If you're curious, the platform is Outreavo, where founders and marketers publish practical articles. Happy to answer questions about the TipTap setup in the comments.

Top comments (0)