Static Site Broken Link Checker
A broken-link checker for static sites, like the ones generated with docsify that can get used, for example, for CI purposes on docsify docs (this is what I've developed it for).
It recursively checks internal links found on the static website (until every internal link is checked) and (without recursion) outgoing links. This is achieved by finding href
attributes in the HTML, meaning also stylesheets included with <link href="some-file.css">
get checked.
You can either run it by just using npx
, in which case you won't have to install it, or first install it with
npm install -g @waylay/ssblc
When you are in the folder of your static website (i.e., there is an index.html
in this folder), simply run
ssblc
after which the checker will begin its work.
To use it with npx
, simply run
npx @waylay/ssblc
Alternatively, you can also specify an absolute or relative path to the directory of the site, e.g., like this:
ssblc --dir ../my-site
If not present, the checker will use the current working directory as the base directory.
Loads a JSON file with context variables for link replacement. The file should contain a JSON object with the following structure:
{
"vars": {
"some-key": "some-value",
"another-key": "another-value"
}
}
The context variables can be used in the href
attributes of the HTML, e.g., <a href="{{vars.some-key}}">Some Link</a>
.
Sets the maximum number of concurrent checks (default: 5).
Sets the protocol timeout for Puppeteer (default: 30000 ms).
Sets the page load timeout for Puppeteer (default: 30000 ms).
Sets the port number for the local server (default: 3000).
Comma-separated list of HTTP statuses to ignore (e.g., 401,403).
If present, exit with code 0 even if errors are found.
ssblc
ssblc --dir ../my-site
ssblc --context context.json
ssblc --port 8080
ssblc --protocol-timeout 60000
ssblc --page-load-timeout 60000
ssblc --max-concurrent-checks 10
ssblc --ignore-statuses 401,403
ssblc --dry-run