Israel Science and Technology Directory

Internet Linkcheck

This page provides instructions for the installation and use of Linkcheck for the Linux systems.

Installing Dart

Linkcheck was developed using Google's Dart programming language. So, the first step in installing linkcheck is installation of Dart.

To install Dart on Debian/Ubuntu systems enter the following in a terminal:

sudo apt-get update; sudo apt-get install dart

Note: If 'dart' is not found, you must first add the Dart repository to your system as described on the page for Dart."

Next, add the Dart bin directory to the $PATH variable:

export PATH="$PATH":"~/.pub-cache/bin"

This command adds the location "$HOME/.pub-cache/bin" to the PATH in Linux. The $PATH variable contains a colon-separated list of directories that can be searched for a command. If the $PATH variable contains the location of the program, the user can run the program from any location within the OS without specifying the full path to the program. An address added to PATH by this command will be valid until the system is reset.

To make this change permanent, append the following line to your ~/.bashrc or ~/.zshrc file.

PATH="$PATH":"$HOME/.pub-cache/bin"

The file .bashrc is located in the HOME directory of the user. Since this is a system file, the name of which starts with a period, the file may be hidden. If the name .bashrc does not appear in the home directory listing, click Ctrl-H to see the hidden files.

Installing linkcheck

To install linkcheck using Dart, enter the following command.

dart pub global activate linkcheck

Verify Linkcheck installation

To verify that Linkcheck is correctly installed and accessible, type:

linkcheck --version

Working with linkcheck in localhost

If there is a local copy of your website in your PC, it is best to check links directly in localhost as shown below:

linkcheck localhost/

By default, linkcheck checks only internal links. To check links to external (remote) sites, add the -e option. To get a report of links that are directed to a different URL, add
--show‑redirects as shown below.

linkcheck -e --show-redirects localhost/

Limiting the range of checking

linkcheck -e --show-redirects --skip-file skip.txt localhost/

The list in skip.txt may include Regular Expressions. Example: The regular expression ^.*\.zip$ tells linkcheck to skip all files with a zip extension.

Redirecting linkcheck report to a file

The default output of linkcheck is the terminal screen. If your website includes many files in many subdirectories, the output may be too long to analyze directly on screen. The output of linkcheck can be directed to a file using standard Linux method of output redirection. For example, to redirect linkcheck's output to a file named lc-report.txt in your /home/username directory, add the command for redirection:

linkcheck -e --show-redirects localhost/ > /home/$USER/lc-report.txt

Updating website directory

After checking and editing the links in your localhost directory, copy the updated files to your website using your favorite FTP software.

ADVERTISEMENT