PHP Script: Sitemap with the number of backlinks
Establishes a map with directories of the site with the number of backlinks for each page.
Works with a CSV file from Google Search Console. For each URL on your site, it displays the number of backlinks and the number from different sites.
Only URLs with at least one backlink are displayed.
The table that the script produces as an HTML file, then allows to judge the popularity of different types of pages on your site, according to the number of links they receive.
Prerequisites:
- The PHP interpreter must be installed.
- Download the list of backlinks from your GSC account, in CSV format.
Display the whole list on and an export button appears to download the file. Do not download the "more" or "latest" CVV files for this program.
The script itself requires no installation. Once extracted from the archive, to build a map from the files, it starts with the command:
php backcount.php
To use a preexisting map, the command is:
php backmap.php
But you must create a backcount.ini file to enter information about your site, it must contain two lines, for example:
site=c:/example.com map:sitemap.xml csv=www-example-com_20140530_ExternalLinks_LinkedPages.csv
The first line indicates the path and name of the csv file.
The second the name of the generated file.
The first is mandatory. If the second is omitted, the name of the ini file will be used with an HTML extension for the name of the file to generate.
If you have multiple sites to manage, you can create an ini file for each one.
The program then generates an HTML table into a file whose name is made from the first part of the name of the CSV file. Directories of your site are in bold and are followed by the list of pages they contain. On each line on the right is the number of backlinks.
Reading this table will indicate clearly which part of the site is the most popular, and which nobody cares.
Pages not listed should either be deleted if the content is not original or de-indexed to improve your site's ranking in search results ... see why in The Panda algorithm made simple.
The archive backcount.zip contains the source code in the Scriptol language and the executable code in PHP.
Versions:
- November 29, 2025. New simplified program tested with the current version of Google Search Console.
- August 21 2015. New simplified version based on the common prefix. The name of the HTML file generated is now composed of the prefix and the full date
- May 20, 2015. Updated for newer PHP versions.
- November 9, 2014. Links to directories were not counted. This is fixed.
- October 23, 2014. Adapted the source code to Scriptol 2. Multiple CSV files now supported. Display now the total of backlinks in the HTML page and in the console.
- June 2014. First version.
The CSV format is often used to produce lists exchangeable between different software. The script above uses simple functions because it is limited to a defined file, but if you want to use this format in your programs with files from different origins, a specialized tool may be useful :
- CSVfix or online version sorts a list alphabetically, search for data, to convert to XML or SQL, to compare two CSV files.
- OpenRefine. Unlike the previous tool that run at command line or online, has a graphical interface. However, it works poorly on large files .

