LOGO

Linkchecker: Automatically Check for Bad Links

October 20, 2011
Linkchecker: Automatically Check for Bad Links

Maintaining Website Health Through Broken Link Detection

Ensuring the continued success of your website or blog within search engine results necessitates consistent monitoring for broken or otherwise invalid links.

This practice benefits not only your site’s search engine optimization (SEO) but also enhances the user experience. Visitors are quickly frustrated by encountering broken links, which reflects negatively on a website’s maintenance.

The Challenge of Manual Link Checking

While periodic manual checks for problematic links are advisable, the process can be quite time-consuming. We have previously highlighted several tools, such as Xenu Link Sleuth as detailed by Ann, and Hyperlink Checker covered by Saikat, to assist with this task.

These tools offer viable solutions, but they still demand a significant time investment. Identifying and addressing broken links inherently requires effort.

Automated Broken Link Detection: A Superior Approach

A more efficient strategy involves implementing an automated script on a server – or any internet-connected computer – to routinely scan your website for broken links.

This script would then generate a comprehensive report detailing any discovered issues. Ideally, this process should be scheduled to run on a recurring basis, such as weekly or monthly.

By automating this task, you eliminate the need for manual intervention until problematic links are identified, streamlining website maintenance and preserving SEO performance.

This proactive approach ensures a consistently positive user experience and reinforces a perception of a well-maintained and reliable online resource.

Utilizing LinkChecker for Website Link Validation

Among the various tools available, LinkChecker stands out as a valuable option for identifying broken links on a website. It has been previously featured in the MUO directory.

The primary advantage of LinkChecker lies in its command-line interface, offering an alternative to traditional graphical user interfaces (GUIs). Executing a link check via the command line involves invoking the linkchecker application, specifying the target URL, and incorporating relevant parameters, which will be detailed shortly.

automate-checking-bad-links-site-linkchecker-1.jpg

A successful execution, devoid of errors, will present a command window displaying a continuous status update regarding the number of links examined by the tool.

automate-checking-bad-links-site-linkchecker-2.jpg

Conversely, the presence of broken links will be indicated by error messages displayed within the command window, as illustrated below.

automate-checking-bad-links-site-linkchecker-3.jpg

While manual script execution is functional, the goal is to automate this process. Understanding the available parameters is crucial for achieving this. A comprehensive list of parameters and flags can be found on the LinkChecker help page; we will concentrate on the -0 and -f parameters, which control output and file handling respectively.

For instance, the command "linkchecker -r1 -ocsv -Fcsv http://www.topsecretwriters.com" generates a CSV file containing all link check results. This file, named "linkchecker-out.csv" by default, is saved in the root LinkChecker directory.

automate-checking-bad-links-site-linkchecker-4.jpg

The resulting CSV file provides a detailed listing of all identified broken links, including the checked link, the date and time the error was detected, and the associated warning or error message.

automate-checking-bad-links-site-linkchecker-5.jpg

This capability allows for the creation of a scheduled task that automatically executes the LinkChecker command. Consequently, a regularly updated CSV file containing a list of all broken links on your website will be generated daily, facilitating prompt correction of these issues.

To establish such a scheduled job, create a batch file containing the aforementioned command (e.g., "CheckLinks.bat") and then schedule its execution via the Task Scheduler, accessible through Start -->Accessories --> System Tools --> Scheduled Tasks.

automate-checking-bad-links-site-linkchecker-6.jpg

Select "Add Scheduled Task" to define the desired execution time and browse to your batch file when prompted.

automate-checking-bad-links-site-linkchecker-7.jpg

For those managing their own web server, an alternative approach involves running the LinkChecker command directly on the server, outputting the results in HTML format, and then publishing this HTML report to a dedicated page on the website for easy access via any web browser.

To generate HTML output, use the following command:

"linkchecker -r1 -ohtml -Fhtml/badlinks.html http://www.topsecretwriters.com"

This command directs the results to an HTML file within the local LinkChecker path. A line should be added to your batch file to move this HTML file to the appropriate directory for your public HTML files. For example:

"MOVE badlinks.html d:/web-server/xampp/htdocs/badlinks/"

This creates a publicly accessible directory (/badlinks/) on your website containing the "badlinks.html" page, displaying the link check results in HTML format.

automate-checking-bad-links-site-linkchecker-8.jpg

This method eliminates the need to log into the server or computer running the script; results can be reviewed directly through the website's dedicated page.

Maintaining the integrity of links on your website is paramount. Links frequently become outdated as referenced web pages are removed or altered, potentially frustrating visitors attempting to follow them.

Therefore, explore the command-line capabilities of LinkChecker to enhance your website's link quality efficiently. Have you implemented this approach, or do you utilize alternative techniques? Share your experiences and insights in the comments below.

Image Credit: Shutterstock

#link checker#broken link checker#bad links#website maintenance#SEO#link validation