Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

Vad är rel=”noopener” i WordPress? (Förklarat)

För några år sedan upptäckte vi att något konstigt hände på en av våra kunders WordPress-webbplatser. Deras besökare omdirigerades till misstänkta webbplatser när de klickade på externa länkar. Det var då vi upptäckte vikten av attributet rel="noopener “.

Säkerhet i WordPress handlar inte bara om starka lösenord och regelbundna uppdateringar. Det handlar också om att förstå tekniska element som kan verka små men som kan ha stor inverkan på din webbplats säkerhet. Attributet rel=”noopener” är ett av dessa viktiga element.

Efter att ha hjälpt hundratals webbplatsägare att säkra sina webbplatser har vi sammanställt den här guiden för att förklara allt du behöver veta om rel="noopener ” i lättförståeliga termer.

What Is rel="noopener" in WordPress? (Explained)

Vad är rel=”noopener” i WordPress?

När du addar links till din WordPress website kan du använda HTML-attribut för att kontrollera vad som händer när du clickar på länken.

När du till exempel skapar en link finns det en toggle switch som allow you att öppna den i en new tab.

Opening a Link in a New Tab

HTML-koden som genereras av WordPress för denna link gillar detta:

<a href="http://example.com" target="_blank" rel="noreferrer noopener">external link</a>

Notera att några HTML-attribut har addats till länken: rel="noopener ” och rel="noreferrer“. Dessa attribut är add to för att åtgärda en säkerhetsbrist.

När du använder target="_blank" för att få en länk att öppnas i en ny flik händer det något potentiellt oväntat bakom kulisserna som standard. Den nya fliken får faktiskt en slags anslutning tillbaka till den ursprungliga fliken som du just var på.

Denna anslutning görs genom något som i webbläsare kallas window.opener. Sidan i den nya fliken kan komma åt och till och med styra vissa egenskaper hos den ursprungliga fliken, som att ändra sidans adress(window.opener.location).

Detta skapar en sårbarhet i säkerheten.

Tänk dig att du klickar på en länk på en betrodd webbplats och att den öppnar en skadlig sida i en ny flik. På grund av denna window.opener-anslutning kan den skadliga sidan potentiellt ändra den ursprungliga betrodda sidan som du just tittade på till en falsk inloggningssida (en phishing-bedrägeri) och lura dig när du byter tillbaka till den ursprungliga fliken.

Länkattributet noopener är utformat för att förhindra denna specifika säkerhetsrisk.

När du lägger till rel="noopener" till en länk som öppnas i en ny flik säger du till webbläsaren att inte skapa den där window.opener-anslutningen mellan de två flikarna. Detta skyddar dina användare från bedrägerier och phishing-försök.

Hur påverkar rel=”noopener” din sökmotorsoptimering i WordPress?

Det gör det inte.

Även om attributet rel="noopener" förbättrar säkerheten på din WordPress-webbplats undviker vissa användare att använda det eftersom de tror att det kommer att påverka sökmotorsoptimeringen i WordPress.

Men det är bara en myt.

Det har ingen inverkan på din sites sökmotorsoptimering eller din övergripande WordPress-prestanda.

Vad är skillnaden mellan “noopener” och “nofollow”?

Det är lätt att förväxla rel="noopener ” med rel="nofollow“. De är dock helt separata attribut.

Attributet noopener skyddar din website från cross-site hacking och förbättrar WordPress säkerhet.

Å andra sidan förhindrar nofollow-attributet din website från att vidarebefordra sökmotorsoptimering till den länkade webben.

Search engines letar efter och tar hänsyn till nofollow-attributet när de följer en länk på din website. De tar dock ej hänsyn till taggen noopener.

Som standard tillåter WordPress inte att du addar nofollow till dina externa links. Om du vill add to nofollow i WordPress måste du använda ett plugin.

För mer information, se vår artikel om hur du lägger till title och nofollow till länkar i WordPress.

Påverkar rel=”noreferrer” affiliate links i WordPress?

Rel="noreferrer" påverkar ej affiliate links i WordPress. Vissa användare tror att det gör det eftersom rel=” noreferrer ” förhindrar att informationen om referraren överförs till den nya tabben.

De flesta affiliate-program ger dig dock en unik URL som har ditt affiliate-ID. Detta innebär att your affiliate ID:n skickas vidare som en URL parameter för den andra website att tracka.

För det andra använder de flesta affiliate-marknadsförare ett plugin för link-cloaking för sina affiliate-länkar.

Med link cloaking är den affiliate-länk som dina användare klickar på faktiskt din websites egen URL, som sedan redirectar användarna till destinations-URL:en.

Hur inaktiverar du rel=”noopener” i WordPress?

Det finns inget behov av att remove rel="noopener ” från links på din website. Det är bra för säkerheten på din website och har ingen inverkan på prestanda eller sökmotorsoptimering på din website.

Men om du måste ta bort det måste du inaktivera Gutenberg Block Editor i WordPress och använda den klassiska editorn.

Det beror på att om du tar bort rel="noopener" från länken manuellt kommer block editor automatiskt att lägga till den igen för att hålla din website säker.

När block editor är inaktiverat måste du lägga till ett code snippet till ditt temas functions.php-fil eller till WPCode-pluginet (rekommenderas). Du kan lära dig hur du använder WPCode Free Plugin i vår guide om hur du enkelt lägger till customize-kod i WordPress.

Kopiera helt enkelt följande kod till ett nytt PHP snippet:

add_filter('tiny_mce_before_init','wpb_disable_noopener');
function wpb_disable_noopener( $mceInit ) {
    $mceInit['allow_unsafe_link_target']=true;
    return $mceInit;
}
Adding a Code Snippet Using WPCode

Se till att du aktiverar toggeln “Active” och klicka sedan på knappen “Save Snippet”.

Detta kommer att hindra WordPress från att lägga till rel="noopener ” till nya links. Du måste också manuellt editera alla gamla links för att ta bort attributet.

Vill du ha ännu mer control över vilka rel-attribut som läggs till i dina links i WordPress? Vi rekommenderar att du använder pluginet AIOSEO eftersom det låter dig add to title, nofollow och andra länkattribut direkt i WordPress editor.

AIOSEO Adds NoFollow and Title Attributes to the Insert Link Popup

Expertguider om hur du använder Links i WordPress

Vi hoppas att den här artikeln hjälpte dig att lära dig mer om rel="noopener ” i WordPress. Du kanske också vill se några andra guider om hur du använder länkar i WordPress:

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

Avatar

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

26 kommentarerLeave a Reply

  1. Moinuddin Waheed

    This is very helpful guide for me as I have been teaching html and css to my students and this for have not talked about these two attributes. Most of the teachers only bother to tell target equals blank attribute for opening link in new tabs.
    The best part is that we have all these options at our end in wordpress as well.
    noopener is good for security reasons as it protects from cross site hacking.
    Thanks for this detailed tutorial.

    • WPBeginner Support

      Glad we could share this :)

      Admin

  2. Oleg Bibik

    Great info, thanks. I now know the difference between noopener and nofollow.

    • WPBeginner Support

      Glad we could help clear that up :)

      Admin

  3. April

    The noopener is also present with the WordPress Classic editor.

    • WPBeginner Support

      True, we cover the block editor as that is the default editor for WordPress.

      Admin

  4. Maria

    Is that ok If i am using “noopener & Noreferrer” for interlinking?

    • WPBeginner Support

      You normally shouldn’t add that for internal links but you can if you would like.

      Admin

  5. Navneet Kumar

    Can we say rel=”noopener no referrer ” provide dofollow backlink to external website?

    I mean if we receive this attribute then we received dofollow backlinks or nofollow backlinks?

    Thanks in advance

    • WPBeginner Support

      These attributes would not affect if a link is dofollow or nofollow, that would be determined if the link is nofollow or not.

      Admin

  6. Nadya

    is it ok to use rel=”noopener noreferrer nofollow” in any position?

    like

    rel=”nofollow noopener noreferrer”
    rel=”noreferrer nofollow noopener”

    • WPBeginner Support

      You shouldn’t need to worry about the order :)

      Admin

  7. Ryan

    Thank you for your article.

    I checked my website on web.dev, and I was confused what is noopener and noreferrer.

    After I put it to all of link with target=”_blank”, my best practice score went from <80 to 86.

    Thank you.

    • WPBeginner Support

      Glad our guide could help, don’t forget that sites with scores like that are mainly suggestions :)

      Admin

  8. Jill

    Hello,

    What about the custom templates used in WordPress? Should rel=”noopener” be used in the links in the custom posts templates? Especially, internal linking?

    • WPBeginner Support

      You would not need to worry about noopener in the links to the templates for your posts and custom post types.

      Admin

  9. Graham

    does this affect Analytics? Yes or no?

    • WPBeginner Support

      noreferrer will prevent Google Analytics from tracking the site that the link came from.

      Admin

  10. Lory

    Can we use noopener but remove noreferrer? Its driving me crazy messing up my analytics. Not only can I not see referral traffic, but I also cannot see which posts have done well over time since referral traffic now shows as direct traffic to my home page. If noopener is the important tag, why is noreferrer included with it? There has to be some way around this.

    • WPBeginner Support

      Unless I hear otherwise, we do not have a specific built-in method to set that up but there are plugins available if you are wanting to remove that from your links.

      Admin

  11. Zol

    Hye WPbeginner Support, O/

    I don’t use plugin to cloak my affiliate links on my website and I just manually add rel=”nofollow” to affiliate links in html editor.

    My question..is this a good practice for SEO ?
    Should I cloak it?

    Thanks in advanced for your reply.. ;)

    • WPBeginner Support

      Hi Zol,

      It is good practice to cloak URLs. It allows you to better manage links, track your affiliate traffic, and makes your URLs look more understandable by both humans and machines.

      Admin

  12. Shyam Mahanta

    My wordpress have ssl certificate (auto ssl from the hosting company) but why the secure lock icon doesn’t appear in the Url? It opens in https but shows connection is not secure. Help is really appreciated.

  13. Seleno

    Hello
    I have affiliate website and since wordpress addded noopener my earnings droped down,

    But i was not sure if it can cause this

    So noopener will never effect the affiliate links ?

    Usualy i’m removing it

    And it will not effect the seo or internal links ?
    Thanks

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.