Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
54 lines (29 sloc) 2.78 KB

Backlinks Plugin

The Backlinks Plugin is for Grav CMS. For each page in your site, it records all other pages that point to it. In wikis, these are commonly called "backlinks."

For a demo, visit my blog.


Installing the Backlinks plugin can be done in one of two ways. The GPM (Grav Package Manager) installation method enables you to quickly and easily install the plugin with a simple terminal command, while the manual method enables you to do so via a zip file.

GPM Installation (Preferred)

The simplest way to install this plugin is via the Grav Package Manager (GPM) through your system's terminal (also called the command line). From the root of your Grav install type:

bin/gpm install backlinks

This will install the Backlinks plugin into your /user/plugins directory within Grav. Its files can be found under /your/site/grav/user/plugins/backlinks.

Manual Installation

To install this plugin, just download the zip version of this repository and unzip it under /your/site/grav/user/plugins. Then, rename the folder to backlinks. You can find these files on GitHub or via

You should now have all the plugin files under


NOTE: This plugin is a modular component for Grav which requires Grav and the Error and Problems plugins to operate.


Before configuring this plugin, you should copy the user/plugins/backlinks/backlinks.yaml to user/config/plugins/backlinks.yaml and only edit that copy.

Here is the default configuration and an explanation of available options:

enabled: true
datafile: 'backlinks.yaml'  # relative to `user/data`
  • The enabled flag turns the plugin off and on.

  • datafile points to a file relative to the user/data folder where you want the backlinks data to live.


The plugin runs during the onShutdown event, which occurs after the connection has been closed with the user, so it should have no impact on user experience. It should also only run once per cache instance—meaning it should only run the first time a page is viewed after the cache is cleared. After that the plugin should be ignored until the cache is cleared again.

The data is made available to Twig templates via the backlinks variable. This contains all the backlink data, not just the data for the requested page. The data is in the form of an associative array:

route => [pages, that, link, to, route]