(Don't) Open Links in a New Window

A discussion on GitHub this morning was the inspiration for this post. It addresses something I've been wanting to do in my software for years, but due to user demand, I haven't.

Why would I want to remove something that so many users seem to want? I'm glad you asked.

The subject of debate is the infamous Open link in a new window checkbox. When checked, this option adds target="_blank" to the link in question. This is a bad idea for a number of reasons.

We Shouldn't Change the Browser's Behavior

It's bad UX to alter the browser's default behavior. People expect things to work a certain way, and when you change that, it becomes frustrating. Not everyone uses the same browser. Not everyone has the same browsing habits.

The thought that you can provide users with a better experience than the one they've spent years growing accustomed to is a terrible misconception.

I'll admit that, in some cases, there are good uses for this behavior. But that should be left up to a web designer to determine, not an end user.

It Can Introduce Security Risks

The age-old method of adding target="_blank" to a link can result in a legitimate security concern that can lead to phishing attacks. Sure, you can add rel="noopener" and hope that supportive clients block it, but there's no guarantee they will — particularly on older browsers.

You may think you're helping your users by opening that link in a new window, but if the resulting page were to become compromised, you'll be introducing them to potentially harmful phishing attacks instead. Not cool.

It's Not Semantic

I'm big on semantics. HTML is intended to markup a document, CSS is intended to style it, and JavaScript is intended to handle behavior.

Adding an attribute to your HTML that modifies behavior is less than desirable. There are more semantic solutions we could use instead, such as rel="external", then the appropriate script can kick in and do what it needs to do. That is, if you really need the link to open in a new window.

Users Shouldn't Have to Think

We're all familiar with Steve Krug's book Don't Make Me Think. He's spot on. The more you make a user think, the worse their experience becomes and the worse the output usually is.

Not only that, littering the UI with toggles and other controls to accommodate superfluous options tempts people to use them — often incorrectly.

The Preferred Approach

Decisions like this need to be made with more thought than most users care to give. Letting them check boxes arbitrarily leads to inconsistent results and poor UX for their visitors.

If the website designer decides that opening links in a new window is the preferred behavior for the website, the correct approach is to use a script to accomplish it.

For example, here's a vanilla JS snippet for opening external links in a new tab/window (source):

function externalLinks() {
  for(var c = document.getElementsByTagName("a"), a = 0;a < c.length;a++) {
    var b = c[a];
    b.getAttribute("href") && b.hostname !== location.hostname && (b.target = "_blank")

This actually provides more flexibility than a checkbox since you can decide if you want to target external links, certain domains, certain media types, or even individual pages. Of course, the flexibility goes to the designer, not the user — but we all know how creative users can get when they have too much control. 😂

In fact, designers can target links with infinite flexibility using JavaScript, but this forces more thought and that's a good thing. It changes one's thinking from "I want this random link to behave differently for whatever reason" to "what makes this type of link unique so that it should open in a new window?"

It also removes all security concerns since we're using JavaScript instead of the trusted target="_blank" approach.

The Postleaf Vision

I'm very opinionated about some topics, and I think that's what makes Postleaf so great. I prefer to think things through instead of blindly implementing them (even if every other CMS in the world already does). I understand people will disagree with me. I'm totally fine with that.

I'm not building Postleaf to be like every other CMS. I want it to be different. That's what makes it so refreshing.

However, I feel it's necessary to point out that decisions like this aren't made arbitrarily. I've been developing content management systems for well over a decade, and this is my opportunity to nail down some of the poorly contrived features we've come to expect in a CMS. (You won't find fonts, colors, or arbitrary text sizes either, for example.)

What you will find is a much simpler experience, both for yourself and your visitors. If this comes at the expense of not having a handful of features you're used to having with other platforms, so be it.

Postleaf is about a different way of thinking. As CMS developers, we've spent years solving problems at the user level, but that's just introduced more problems for designers and visitors.

I believe we should solve more things at the designer level. Let the people who are trained to make these decisions make them.

When we do that, everyone wins.