Extension:AdvancedBacklinks

The AdvancedBacklinks extension greatly extends MediaWiki's backlink tracking capability by tracking through what templates a page is linked through. It indexes wikilinks and imagelinks while preserving more information about them than MediaWiki's parser. This extension only registers the first level of transclusion. This is due to limitations in Parsoid.

It's main purpose is to help with tracking backlinks on wikis that use navboxes or similar templates with large amounts of links. This extension can filter out backlinks that are added through templates and show the user only direct wikitext links. This has been a long-requested feature on Wikipedia and other wikis, see these three tasks on Phabricator for more details: T3392, T5241, T14396. This extension is currently under active development lead by Nonsensopedia's community.

Install Parsoid
AdvancedBacklinks uses Parsoid to parse pages on the wiki and extract information about templates and links. Parsoid is used, as there is apparently no way to hook into MediaWiki's parser to extract all needed information. This may change in the future, but for now Parsoid is (unfortunately) a hard dependency.

If you already have VisualEditor installed and working, you probably don't have to do anything and you are good to go. If you don't have VisualEditor installed, you have to first set up Parsoid on your server. Then you have to set up the  variable in your LocalSettings.php, exactly as you would with VisualEditor. Please follow VE's instructions in this section of its installation manual. AdvancedBacklinks can also work with RESTBase, if  is configured properly (again, see VE's installation manual for more details).

Configuration

 * $wgAdvancedBacklinksTrackExtlinks: Whether to include external links to the same wiki (like ) during indexing wikilinks. Default is true, which is consistent with default MediaWiki's behaviour.

Special:AdvancedBacklinks
A page that replaces Special:WhatLinksHere. The What links here link in sidebar is automatically changed to point to Special:AdvancedBacklinks. This special page exposes a very similar interface to that of Special:WhatLinksHere, but with a couple new features:
 * The ability to show only direct links from pages (in wikitext). That excludes all links that are transcluded by templates. To do that, please check the Wikitext links only option.
 * Links are displayed in a tree-like structure. Links that are transcluded through a template are shown as children of that template.

Let's assume we have four pages on our wiki, A, B, C and D. We also have a template called Navbox that has a link to A in it. This template is transcluded by B and C. D has a direct link in wikitext to A.
 * Example

What would Special:AdvancedBacklinks/A show?
 * D
 * Navbox (through transclusion)
 * B
 * C

__DIRECTLINK__ magic word
If you want a certain template not to appear in the transclusion tree on Special:AdvancedBacklinks, you can do so by placing a __DIRECTLINK__ magic word in that template. This will make the template transparent to the extension during indexing. One possible use case is templates for making a certain type of link easily, like colored links.

Maintenance
If you find in your database wikilinks or imagelinks from a nonexistent page, you can clean them up using the RemoveBrokenLinks.php script provided in the maintenance folder. Broken links can appear in the database after some kind of software failure or manual intervention. They should not appear during normal operation.