The rel attribute specifies the relationship between the current document and the linked document. Search engines can use this attribute to get more information about a link.

rel Attribute Values

nofollowLinks to an unendorsed document, like a paid link.
(“nofollow” is used by Google, to specify that the Google search spider should not follow that link)
noreferrerRequires that the browser should not send an HTTP referer header if the user follows the hyperlink
noopenerRequires that any browsing context created by following the hyperlink must not have an opener browsing context

Add the following code into your HTML page between the <head> and </head> tags or before the closing </body> tag

    document.addEventListener('DOMContentLoaded', function () {
        var links = document.getElementsByTagName("a");
        var i;
        for (i = 0; i < links.length; i++) {
            if (location.hostname !== links[i].hostname) {
                links[i].rel = "nofollow noopener noreferrer";
                links[i].target = "_blank";