Manuel:$wgNoFollowLinks

From mediawiki.org
This page is a translated version of the page Manual:$wgNoFollowLinks and the translation is 89% complete.
Analyseur syntaxique: $wgNoFollowLinks
S'il vaut true, les liens d'URL externe dans le texte du wiki recevront l'attribut rel="nofollow".
Introduit dans la version :1.4.0 (r7174)
Retiré dans la version :Encore utilisé
Valeurs autorisées :(booléen)
Valeur par défaut :true

Détails

S'il vaut true, les liens d'URL externe donnés en texte wiki recevront l'attribut rel="nofollow" comme une indication pour les moteurs de recherche qu'ils ne devraient pas être suivis à des fins de classement, car ils sont fournis par les utilisateurs et donc sujets à pollution. true est la valeur par défaut.

Setting nofollow for red links

It may be desirable to configure MW to append rel="nofollow" to internal links that point to pages that haven't yet been written (so-called "red links") for various reasons that include avoiding unnecessary crawler traffic to non-extant pages or for the possibility of improved SEO by avoiding punitive action against a site's ranking due to the presence of "broken links" that aren't broken, just not yet authored.

This may be accomplished by using the HtmlPageLinkRendererEnd hook as follows:

// Add rel="nofollow" to links to pages that don't exist (redlinks)
$wgHooks['HtmlPageLinkRendererEnd'][] = 'noFollowRedLinks';
function noFollowRedLinks(
    $linkRenderer, $target, $isKnown, &$text, &$attribs, &$ret)
{
    if (!$isKnown && preg_match('/\bnew\b/S', $attribs['class'] ?? "")) {
        $attribs['rel'] = 'nofollow';
    }
    return true;
}

Voir aussi