matteocontrini Good idea. I’ll add noopener. Seems like one day the default for target blank will be noopener. At least that’s what some are pushing. Or, nofollow and noopener together.

New Release

  • Added noopener and nofollow to external links. One is for security the other is for SEO.

    010101 How about do something like this as there are already nofollow and ugc when needed?

    var rel = $('.External-link').attr('rel');
    $('.External-link').attr('target','_blank').attr('rel',rel + ' noopener');

      Gatsu I believe that one you linked to opens ALL links in an external tab. This only opens external links in a new tab. Internal links, such as ones to another post or page within your forum open in the same window. Therefore, users stay on your site when the link is something on your site, but they leave when the link is not part of your site. This also adds "noopener" which is about security. Many may disagree, but in my opinion, this is how links should work naturally in browsers. If link is part of the site, you stay on that site. If not, you get a new tab/window. Many will also say that you should let the user decide. You can right click and open any link in a new tab. I actually 99% agree with that. EXCEPT, believe it or not, there are users out there who may not know or think about right clicking.

      wloot

      New Release

      • Thanks to wloot, the attributes are now coded better. Now the extension will use the already existing nofollow and ugc in Flarum core, but add the noopener as well for security.
      • The previous poster brought up a good question that you too may be wondering so be sure to read the previous post as well about the difference between this and Franz's external link extension.
      a month later

      Hey, found a bug

      External links have this attribute added to them:

        danielunited Must have something to do with an embed extension. Normal external links I’ve tested do not look like that.

        If you post a normal external link such as, google.com, what happens?

          010101 It happens to all external links - including the ones on the menu. It doesn't happen to internal links (which point to other discussions).

          It's not related to the embed extension. I know because when I dsiabled elint these links work fine (with just nofollow ugc).

            010101 your code is selecting all the links on the page every time a post is rendered, so it adds the attribute many times. jQuery shouldn't really be used with Flarum unless strictly necessary, there's almost always a better way to do it

              010101 sorry if I've been rude, I just wanted to point out that the Flarum frontend is better extended by using the frontend API and avoiding jQuery as much as possible, so that issues like this are less likely to happen. It's true however that Flarum's extension development is currently very poorly documented so it's quite hard to understand how to do things properly...

                matteocontrini No worries. It’s just a little frustrating because I can customize something like a WordPress site all day long, but Flarum just cannot be customized (besides some basics with CSS) by your average website owner. Still, I’m a fan of Flarum. And, this particular feature I don’t really know if it’s even important or not.

                Even if all links (external too) open in the same window, some say that’s best... Let the user use their browser back button. This whole opening certain links in new windows thing is something I go back and forth on repeatedly. Does it really matter? Maybe Flarum core has made the right decision to open ALL links in the same window. The user needs to utilize their browser features. Go back as needed.

                All I know is, more and more, I’m finding myself sticking with only core extensions and some fof extensions and that’s about it because too many issues arise when you add too many extensions or try to do something “fancy.”

                Using this.$(selector) instead of $(selector) will limit the results to children of the current component. This is a jQuery shortcut offered by Flarum. I think this would solve the issue.