The Perl Advent Calendar needs more articles for 2022. Submit your idea today!


checklink - check the validity of links in an HTML or XHTML document


checklink [ options ] uri ...


This manual page documents briefly the checklink command, a.k.a. the W3C® Link Checker.

checklink is a program that reads an HTML or XHTML document, extracts a list of anchors and lists and checks that no anchor is defined twice and that all the links are dereferenceable, including the fragments. It warns about HTTP redirects, including directory redirects, and can check recursively a part of a web site.

The program can be used either as a command line tool or as a CGI script.


This program follow the usual GNU command line syntax, with long options starting with two dashes (`-'). A summary of options is included below.

-?, -h, --help

Show summary of options.

-V, --version

Output version information.

-s, --summary

Show result summary only.

-b, --broken

Show only the broken links, not the redirects.

-e, --directory

Hide directory redirects - e.g. ->

-r, --recursive

Check the documents linked from the first one.

-D, --depth n

Check the documents linked from the first one to depth n (implies --recursive).

-l, --location uri

Scope of the documents checked (implies --recursive). Can be specified multiple times in order to specify multiple recursion bases. If the URI of a candidate document is downwards relative to any of the bases, it is considered to be within the scope. If not specified, the default is the base URI of the initial document, for example for it would be

--exclude-docs regexp

In recursive mode, do not check links in documents whose URIs match regexp.

-L, --languages accept-language

The Accept-Language HTTP header to send. In command line mode, this header is not sent by default. The special value auto causes a value to be detected from the LANG environment variable, and sent if found. In CGI mode, the default is to send the value received from the client as is.

-q, --quiet

No output if no errors are found.

-v, --verbose

Verbose mode.

-i, --indicator

Show progress while parsing.

-u, --user username

Specify a username for authentication.

-p, --password password

Specify a password for authentication.


Hide 401's that are in the same realm as the document checked.

-S, --sleep secs

Sleep the specified number of seconds between requests to each server. Defaults to 1 second, which is also the minimum allowed.

-t, --timeout secs

Timeout for requests, in seconds.

-d, --domain domain

Perl regular expression describing the domain to which the authentication information (if present) will be sent. The default value can be specified in the configuration file. See the Trusted entry in the configuration file description below for more information.

--masquerade "local remote"

Masquerade local dir as a remote URI. For example, the following results in /my/local/dir/ being "mapped" to http://some/remote/uri/

  --masquerade "/my/local/dir http://some/remote/uri/"

As of revision of checklink, --masquerade takes a single argument consisting of two URIs, separated by whitespace. One usual way of providing a value with embedded whitespace is to enclose it in quotes.

-H, --html

HTML output.



The main configuration file. You can use the W3C_CHECKLINK_CFG environment variable to override the default location.

Trusted specifies a regular expression for matching trusted domains (ie. domains where HTTP basic authentication, if any, will be sent). The regular expression will be matched case insensitively against host names. The default behavior (when unset, that is) is to send the authentication information only to the host which requests it; usually you don't want to change this. For example, the following configures only the domain as trusted:

    Trusted = \.w3\.org$

Allow_Private_IPs is a boolean flag indicating whether checking links on non-public IP addresses is allowed. The default is true in command line mode and false when run as a CGI script. For example, to disallow checking non-public IP addresses, regardless of the mode, use:

   Allow_Private_IPs = 0

Markup_Validator_URI and CSS_Validator_URI are formatted URIs to the respective validators. The %s in these will be replaced with the full "URI encoded" URI to the document being checked, and shown in the link checker results view in the online/CGI version. The defaults are:

   Markup_Validator_URI =
   CSS_Validator_URI =

Doc_URI and Style_URI are URIs used for linking to the documentation and style sheet from the dynamically generated content of the link checker. The defaults are:

   Doc_URI =
   Style_URI =


checklink uses the libwww-perl library which has a number of environment variables affecting its behaviour. See "SEE ALSO" for some pointers.

If set, overrides the path to the configuration file.


The documentation for this program is available on the web at

LWP, Net::FTP, Net::NNTP, Net::IP, perlre.


This program was originally written by Hugo Haas <>, based on Renaud Bruyeron's It has been enhanced by Ville Skyttä and many other volunteers since. Use the <> mailing list for feedback, and see for more information.

This manual page was written by Frédéric Schütz <> for the Debian GNU/Linux system (but may be used by others).


This program is licensed under the W3C® Software License,

1 POD Error

The following errors were encountered while parsing the POD:

Around line 14:

Non-ASCII character seen before =encoding in 'W3C®'. Assuming UTF-8