3

How can I automatically handle hyperlinks leading outside my site?
Let's speak about site without user-contributed posts/comments so I can have admin access to all external links.

I would like to

  1. equip every external link with indicator similar to wikipedia-style external link icon

  2. automatically open external links in new window (target="_blank")

  3. optionally

    3.1. mass-check external links for validity (indicate broken links) so I can fix them

    3.2. collect extenal link click statistics

    3.3. get possibility to display exit page (or tooltip) with information or disclaimer before leaving the site

  • If you want to manually check for 404 links then a desktop tool like xenu (Windows only) or Screaming Frog is very handy. You can also set a notification in your 404 template to mail you when someone hits the 404 page with an internal link referrer. Then you just need to fix the ones that people have tried to use. – Robert Went Jul 30 '17 at 0:21
  • Example for sending a 404 to admin when it's a link from a referring page github.com/robwent/joomlapure/blob/master/source/tpl_joomlapure/… – Robert Went Jul 30 '17 at 0:24
5
  1. The first one is very easy, you can do that with just some css assuming you haven't added http:// to all your internal links then you can target external ones like this:

    a[href^="http://"] {…}

    Then you can apply any styling you like, including a background image or icon to those links.

  2. If you have access to all the links simply add the code you gave to each:

    The default behaviour is to not do that of course, so you must either add that attribute to each or subvert this behaviour with Javascript, like this: http://css-tricks.com/snippets/jquery/open-external-links-in-new-window/

    • 3.1. Use Webmaster Tools.

    • 3.2 You can collect link stats by using com_weblinks to create links and then track the results.

    • 3.3. Javascript.

1

To open external links in a new window you could use this free plugin.

I also highly recommend using sh404SEF which apart from being able to mark external links also gives you great control of your SEF links, tracks 404 errors and adds to your sites' security.
Note: I have no affiliation to it other than being a happy customer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.