Skip to content

Commit

Permalink
Mark red links as nofollow
Browse files Browse the repository at this point in the history
  • Loading branch information
alistair3149 committed Nov 13, 2024
1 parent 621d06d commit 38354b5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions config/LocalSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -1386,6 +1386,18 @@
return true;
};

/**
* Append rel="nofollow" to red links to avoid unnessecary crawler traffic
*
* @see https://www.mediawiki.org/wiki/Manual:$wgNoFollowLinks
*/
$wgHooks['HtmlPageLinkRendererEnd'][] = function( $linkRenderer, $target, $isKnown, &$text, &$attribs, &$ret ) {
if ( !$isKnown && preg_match( '/\bnew\b/S', $attribs['class'] ?? '' ) ) {
$attribs['rel'] = 'nofollow';
}
return true;
};

/**
* Extend "Installed software" section in Special:Version
*
Expand Down

0 comments on commit 38354b5

Please sign in to comment.