Manual:$wgNoFollowLinks
From Linux Web Expert
<translate> Parser</translate>: $wgNoFollowLinks | |
---|---|
If true, external URL links in wiki text will be given the rel="nofollow" attribute. |
|
<translate> Introduced in version:</translate> | 1.4.0 (r7174) |
<translate> Removed in version:</translate> | <translate> still in use</translate> |
<translate> Allowed values:</translate> | (boolean) |
<translate> Default value:</translate> | true |
<translate> Other settings:</translate> <translate> Alphabetical</translate> | <translate> By function</translate> |
Details
If true, external URL links in wiki text will be given the rel="nofollow"
attribute as a hint to search engines that they should not be followed for ranking purposes as they are user-supplied and thus subject to spamming. Defaults to true.
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;
}
See also
- $wgNoFollowDomainExceptions
- $wgNoFollowNsExceptions
- Extension:Interwiki - the easiest way to manage whitelisting (since nofollow is not applied to interwiki links)
- Manual:Nofollow
- meta:nofollow, Meta-Wiki discussion on nofollow's use on Wikimedia sites. Some of the arguments raised there may also applicable to other wikis' decisions concerning this configuration setting.