Available from version 1.28.0 (Gerrit change 284750)

Define function:
public static function onHtmlPageLinkRendererBegin( LinkRenderer $linkRenderer, LinkTarget $target, &$text, &$extraAttribs, &$query, &$ret ) { ... }
Attach hook: In extension.json:
	"Hooks": {
		"HtmlPageLinkRendererBegin": "MediaWiki\\Extension\\MyExtension\\Hooks::onHtmlPageLinkRendererBegin"
Called from: File(s): linker/LinkRenderer.php
Function(s): LinkRenderer::runBeginHook()
Interface: HtmlPageLinkRendererBeginHook.php

For more information about attaching hooks, see Manual:Hooks .
For examples of extensions using this hook, see Category:HtmlPageLinkRendererBegin extensions.

Used when generating internal and interwiki links in LinkRenderer, before processing starts. Return false to skip default processing and return $ret.


  • $linkRenderer: the LinkRenderer object
  • $target: the LinkTarget that the link is pointing to
  • &$text: the contents that the <a> tag should have; either a plain, unescaped string or a HtmlArmor object; null means "default".
  • &$customAttribs: the HTML attributes that the <a> tag should have, in associative array form, with keys and values unescaped. Should be merged with default values, with a value of false meaning to suppress the attribute.
  • &$query: the query string to add to the generated URL (the bit after the "?"), in associative array form, with keys and values unescaped.
  • &$ret: the value to return if your hook returns false.

See also