By james, 4 December, 2022
Advent Calendar door 4 containing External Links icon

I really like modules that you can just install and forget about, and they just make your site better, and behind today’s door we find one of those.

Links can be messy to deal with, especially when they point to locations external to your website. Sometimes you may not want to lose your site visitors, so you might want to open the link in a new browser tab, so that they can come back to your site easily. You can do this by adding target=”_blank” to your link, and that will work fine, but having to remember to do that every time you add a new link can be challenging. Also, for visitors to your site, it can be nice to know will a link take them off the site or not before they click it.

Enter the External Links module. And there, you can see what it does already. It identifies links, anywhere on the site, and if the link points somewhere off the site, it adds a visual indicator to warn the user. It can also make any external links open in a new tab, which I have enabled.

For most sites you can just enable the module, and decide if you want external links to open a new tab in the settings, and then let it do the rest. You don’t need to do anything special when inserting links, just create links as normal, and let External Links figure out how to deal with them.

But sometimes you may need to deal with exceptions, such as if your site domain changed. You can set regular expressions to select alternative domains that should be treated as local. It also has an option to treat any subdomains of the same second level domain as local. However, once this has been configured, everything should work automatically.

And there’s not much more that needs to be said about External Links. Which is a good thing.

As I said at the start, I like this sort of module that once you enable it, your site improves and you don’t need to do anything to take advantage of it.

I hope you are enjoying these posts. Please come back tomorrow for something a little different.

Advent Calendar with door 4 open showing External Links logo.

 

Comments

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.