External links in the pihole menu

Since the feature request to add external links to the pihole menu has obviously been denied, here is the solution to add it yourself. Unfortunately, pihole -up and pihole -r will kill the change, so you need to implement it every time. To make this less time consuming, a script is included to make the change for you.

TESTED ON Pi-hole Version v4.1.1 Web Interface Version v4.1.1 FTL Version v4.1.2

STEP 1: create a new php script /var/www/html/admin/scripts/pi-hole/php/externalurl.php, content:

<li class="treeview active">
	<a href="#">
		<span class="pull-right-container">
			<i class="fa fa-angle-down pull-right" style="padding-right: 5px;"></i>
		<i class="fa fa-folder"></i> <span>External Links</span>
    <ul class="treeview-menu">
		if(file_exists("/etc/pihole/links.conf")) {
			$file = fopen("/etc/pihole/links.conf", "r") or exit("Unable to open file!");
			while(!feof($file)) {
				$array = explode(',', fgets($file));
					<a href="<?php echo "$array[1]"; ?>" target="_blank">
					<i class="fa fa-newspaper-o"></i> <span><?php echo "$array[0]"; ?></span>

STEP2: create the configuration file /etc/pihole/links.conf, populated with the links you want. Example:

sql browser,

Syntax: name, url
The separator is a comma
There should NOT be a new line after the last entry, as it will create an empty menu item.
The webmin installation is explained here , section 4.11
The sql browser installation is explained here .

STEP 3: run this script (sudo) to make the necessary changes to /var/www/html/admin/scripts/pi-hole/php/header.php, content:


line=$(grep "<!-- External Links -->" $file)
if [ $? -eq 1 ]; then
	echo "added"
	sudo sed -i 's/<!-- Donate -->/<!-- External Links -->\n&/' $file
	sudo sed -i 's/<!-- Donate -->/<?php include "scripts\/pi-hole\/php\/externalurl.php"; ?>\n&/' $file

The result:

Beware, discourse sometimes changes double quotes into something else, when copy / pasting the content, so check your copy well!!!

the necessary files can now be retrieved from github