-
AuthorPosts
-
February 20, 2019 at 2:59 pm #1069486
Hi
You should add rel=”noopener noreferrer” on all links with target=”_blank”https://developers.google.com/web/tools/lighthouse/audits/noopener
February 21, 2019 at 10:29 am #1069855Hey enestedt,
Thanks for sharing, have we missed adding that somewhere?
Best regards,
RikardFebruary 21, 2019 at 12:40 pm #1069905But please read carefully.
Recommendations
Add rel=”noopener” or rel=”noreferrer” to each of the links that Lighthouse has identified in your report. In general, when you use target=”_blank”, always add rel=”noopener” or rel=”noreferrer”.
Or : means – nofollow will be enough to add.
btw: you can reach this via child-theme functions.php
adjust the webers-testseite.de through your home domain url:add_action('wp_footer', 'open_external_links_in_newtab'); function open_external_links_in_newtab(){ ?> <script type="text/javascript"> (function($) { $('a').not('a[href*="webers-testseite.de"]').attr({ 'target':'_blank', 'rel': 'nofollow', }) })(jQuery); </script> <?php }
means that any link that does not match your domain url will be considered external and will be opened in a new tab with the attribute nofollow.
February 21, 2019 at 1:02 pm #1069912Hi Rikard
I downloaded the theme 20/2 2019 and in that theme files I get a lot of taget _blank, maybe you can look in to them and see if its necessary track where the link comes from.
But the one I’m most concerned about is the social links added via the theme settings (social profiles).
It would be nice if those links had noopener and/or noreferrer, at least an option for me as a user to add me own rel options :)
@Guenni007
I still want google to follow the social links so nofollow is out of the question.
But I don’t want someone to “hijack” the site
https://support.performancefoundry.com/article/186-noopener-noreferrer-on-my-linksFebruary 21, 2019 at 1:08 pm #1069917ok – take this code to child-theme functions.php:
add_action('wp_footer', 'open_external_links_in_newtab'); function open_external_links_in_newtab(){ ?> <script type="text/javascript"> (function($) { $('a').not('a[href*="webers-testseite.de"]').attr({ 'target':'_blank', 'rel': 'nofollow noreferrer', }) })(jQuery); </script> <?php }
but read on your link above : Collateral damage and https versus http
so it might be better to only do this to links which starts with http only:
add_action('wp_footer', 'open_external_links_in_newtab'); function open_external_links_in_newtab(){ ?> <script type="text/javascript"> (function($) { $('a[href^="http:"]').not('a[href*="webers-testseite.de"]').attr({ 'target':'_blank', 'rel': 'nofollow noreferrer', }) })(jQuery); </script> <?php }
-
AuthorPosts
- You must be logged in to reply to this topic.