
Xrefcheck is a tool for verifying local and external references in a repository's documentation that is quick, easy to setup, and suitable to be run on a CI pipeline.
As a project evolves, links in markdown documentation have a tendency to become broken. This is usually because:
This tool will help you to keep references in order.
You can run xrefcheck continuously in your CI pipeline,
and it will let you know when it finds a broken link.
Comparing to alternative solutions, this tool tries to achieve the following points:
HEAD request; only when that fails does it try a GET request.xrefcheck will wait the requested amount of seconds before retrying.xrefcheck in the repository root.http, https, ftp and ftps).Xrefcheck requires you to have git version 2.18.0 or later in your PATH.
We provide the following ways for you to use xrefcheck:
mkdir -p bin/
wget --quiet -O bin/xrefcheck https://serokell.gateway.scarf.sh/xrefcheck/latest/xrefcheck-x86_64-linux
chmod +x bin/xrefcheck
bin/xrefcheck
docker pull serokell.docker.scarf.sh/serokell/xrefcheck
nix shell -f https://github.com/serokell/xrefcheck/archive/master.tar.gz -c xrefcheck
If none of those are suitable for you, please open an issue!
To find all broken links in a repository, simply run xrefcheck from its root folder:
xrefcheck
To also display a list of all links and anchors:
xrefcheck --verbose
For description of other options:
xrefcheck --help
To configure xrefcheck, run:
xrefcheck dump-config --type GitHub
This will create a .xrefcheck.yaml file with all the configuration
options, here's an example.
This file should be committed to your repository.
Run stack install to build everything and install the executable.
If you wish to use cabal, you need to run stack2cabal first!
On Windows, executable requires some dynamic libraries (DLLs).
They are shipped together with executable in releases page.
If you have built executable from source using stack install,
those DLLs are downloaded by stack to a location that is not on %PATH% by default.
There are several ways to fix this:
%LocalAppData%\Programs\stack\x86_64-windows\msys2-<...>\mingw64\bin to your PATHstack exec xrefcheck.exe -- <args> instead of xrefcheck.exe <args>xrefcheck.exeHow do I ignore specific files?
--ignore <glob pattern> command-line option,
or the ignore list in the config file. Links to those files will be reported as errors, links from those files will not be verified.How do I ignore specific links?
ignoreLocalRefsTo or ignoreExternalRefsTo lists in the config file.<!-- xrefcheck: ignore link --> annotation before the link:
<!-- xrefcheck: ignore link -->
Link to some [invalid resource](https://fictitious.uri/).
A [valid link](https://www.google.com)
followed by an <!-- xrefcheck: ignore link --> [invalid link](https://fictitious.uri/).
<!-- xrefcheck: ignore paragraph --> annotation to ignore all links in a paragraph.How do I ignore all links from a specific markdown file?
ignoreRefsFrom list in the config file.<!-- xrefcheck: ignore all --> at the top of the file.How do I ignore all external links?
--mode local-only.How does xrefcheck handle links that require authentication?
xrefcheck attempts to verify a link and is faced with a 403 Forbidden or a 401 Unauthorized, it assumes the link is valid.ignoreAuthFailures: false in the config file.How does xrefcheck handle redirects?
The rules from the default configuration are as follows:
Redirect rules can be specified with the externalRefRedirects parameter within networking, which accepts an array of
rules with keys from, to, on and outcome. The rule applied is the first one that matches with
the from, to and on fields, if any, where
from is a regular expression, as in ignoreExternalRefsTo, for the source link in a single redirection step. Its absence means that
every link matches.to is a regular expression for the target link in a single redirection step. Its absence also means that every link matches.on accepts temporary, permanent or a specific redirect HTTP code. Its absence also means that
every response code matches.outcome parameter accepts valid, invalid or follow. The last one follows the redirect by applying the
same configuration rules.For example, this configuration forbids 307 redirects to a specific domain and makes redirections from HTTP to HTTPS to be followed:
externalRefRedirects:
- to: "https?://forbidden.com.*"
on: 307
outcome: invalid
- from: "http://.*"
to: "https://.*"
outcome: follow
The first one applies if both of them match.
The number of redirects allowed in a single redirect chain is limited and can be configured with the
maxRedirectFollows parameter, also within networking. A number smaller than 0 disables the limit.
How does xrefcheck handle localhost links?
xrefcheck will ignore links to localhost.ignoreExternalRefsTo list in the config file.find.
This tool requires some configuring before it can be applied to a repository or added to CI.mailto: link resolution.HTML files. There are other solutions for this particular task which we don't mention here.At the moment of writing, the listed solutions don't support ftp/ftps links.
We use GitHub issues as our issue tracker. You can login using your GitHub account to leave a comment or create a new issue.
Please see CONTRIBUTING.md for more information.
Xrefcheck is maintained and funded with ❤️ by Serokell. The names and logo for Serokell are trademark of Serokell OÜ.
We love open source software! See our other projects or hire us to design, develop and grow your idea!
Haskell
82.6%
Shell
9.1%
Ruby
4.8%
Nix
2.2%
Makefile
1.3%

Xrefcheck is a tool for verifying local and external references in a repository's documentation that is quick, easy to setup, and suitable to be run on a CI pipeline.
As a project evolves, links in markdown documentation have a tendency to become broken. This is usually because:
This tool will help you to keep references in order.
You can run xrefcheck continuously in your CI pipeline,
and it will let you know when it finds a broken link.
Comparing to alternative solutions, this tool tries to achieve the following points:
HEAD request; only when that fails does it try a GET request.xrefcheck will wait the requested amount of seconds before retrying.xrefcheck in the repository root.http, https, ftp and ftps).Xrefcheck requires you to have git version 2.18.0 or later in your PATH.
We provide the following ways for you to use xrefcheck:
mkdir -p bin/
wget --quiet -O bin/xrefcheck https://serokell.gateway.scarf.sh/xrefcheck/latest/xrefcheck-x86_64-linux
chmod +x bin/xrefcheck
bin/xrefcheck
docker pull serokell.docker.scarf.sh/serokell/xrefcheck
nix shell -f https://github.com/serokell/xrefcheck/archive/master.tar.gz -c xrefcheck
If none of those are suitable for you, please open an issue!
To find all broken links in a repository, simply run xrefcheck from its root folder:
xrefcheck
To also display a list of all links and anchors:
xrefcheck --verbose
For description of other options:
xrefcheck --help
To configure xrefcheck, run:
xrefcheck dump-config --type GitHub
This will create a .xrefcheck.yaml file with all the configuration
options, here's an example.
This file should be committed to your repository.
Run stack install to build everything and install the executable.
If you wish to use cabal, you need to run stack2cabal first!
On Windows, executable requires some dynamic libraries (DLLs).
They are shipped together with executable in releases page.
If you have built executable from source using stack install,
those DLLs are downloaded by stack to a location that is not on %PATH% by default.
There are several ways to fix this:
%LocalAppData%\Programs\stack\x86_64-windows\msys2-<...>\mingw64\bin to your PATHstack exec xrefcheck.exe -- <args> instead of xrefcheck.exe <args>xrefcheck.exeHow do I ignore specific files?
--ignore <glob pattern> command-line option,
or the ignore list in the config file. Links to those files will be reported as errors, links from those files will not be verified.How do I ignore specific links?
ignoreLocalRefsTo or ignoreExternalRefsTo lists in the config file.<!-- xrefcheck: ignore link --> annotation before the link:
<!-- xrefcheck: ignore link -->
Link to some [invalid resource](https://fictitious.uri/).
A [valid link](https://www.google.com)
followed by an <!-- xrefcheck: ignore link --> [invalid link](https://fictitious.uri/).
<!-- xrefcheck: ignore paragraph --> annotation to ignore all links in a paragraph.How do I ignore all links from a specific markdown file?
ignoreRefsFrom list in the config file.<!-- xrefcheck: ignore all --> at the top of the file.How do I ignore all external links?
--mode local-only.How does xrefcheck handle links that require authentication?
xrefcheck attempts to verify a link and is faced with a 403 Forbidden or a 401 Unauthorized, it assumes the link is valid.ignoreAuthFailures: false in the config file.How does xrefcheck handle redirects?
The rules from the default configuration are as follows:
Redirect rules can be specified with the externalRefRedirects parameter within networking, which accepts an array of
rules with keys from, to, on and outcome. The rule applied is the first one that matches with
the from, to and on fields, if any, where
from is a regular expression, as in ignoreExternalRefsTo, for the source link in a single redirection step. Its absence means that
every link matches.to is a regular expression for the target link in a single redirection step. Its absence also means that every link matches.on accepts temporary, permanent or a specific redirect HTTP code. Its absence also means that
every response code matches.outcome parameter accepts valid, invalid or follow. The last one follows the redirect by applying the
same configuration rules.For example, this configuration forbids 307 redirects to a specific domain and makes redirections from HTTP to HTTPS to be followed:
externalRefRedirects:
- to: "https?://forbidden.com.*"
on: 307
outcome: invalid
- from: "http://.*"
to: "https://.*"
outcome: follow
The first one applies if both of them match.
The number of redirects allowed in a single redirect chain is limited and can be configured with the
maxRedirectFollows parameter, also within networking. A number smaller than 0 disables the limit.
How does xrefcheck handle localhost links?
xrefcheck will ignore links to localhost.ignoreExternalRefsTo list in the config file.find.
This tool requires some configuring before it can be applied to a repository or added to CI.mailto: link resolution.HTML files. There are other solutions for this particular task which we don't mention here.At the moment of writing, the listed solutions don't support ftp/ftps links.
We use GitHub issues as our issue tracker. You can login using your GitHub account to leave a comment or create a new issue.
Please see CONTRIBUTING.md for more information.
Xrefcheck is maintained and funded with ❤️ by Serokell. The names and logo for Serokell are trademark of Serokell OÜ.
We love open source software! See our other projects or hire us to design, develop and grow your idea!
Haskell
82.6%
Shell
9.1%
Ruby
4.8%
Nix
2.2%
Makefile
1.3%