Getting Started
You can install Lychee using various package managers.
pacman -S lycheebrew install lycheedocker pull lycheeverse/lycheenix-env -iA nixos.lycheepkg install lycheescoop install lycheesudo snap install lycheezypper in lycheewinget install lycheeverse.lycheechoco install lycheePre-built binaries
Section titled “Pre-built binaries”Lychee provides binaries for Linux, macOS, and Windows for every release. You can download them from the releases page.
Docker
Section titled “Docker”Lychee provides a handy official image over at lycheeverse/lychee, which is updated on every release.
To check files on your local machine, you need to mount them into the Docker container.
Here’s how to do that:
docker run --init -it -v `pwd`:/input lycheeverse/lychee /input/README.mdThe --init parameter is passed so that lychee can be stopped
from the terminal. We also pass -it to start an interactive terminal, which
is required to show the progress bar.
Build dependencies
Section titled “Build dependencies”On APT/dpkg-based Linux distros (e.g. Debian, Ubuntu, Linux Mint and Kali Linux) the following commands will install all required build dependencies, including the Rust toolchain and cargo:
curl -sSf '<https://sh.rustup.rs>' | shapt install gcc pkg-config libc6-dev libssl-devCompile and install lychee
Section titled “Compile and install lychee”cargo install lycheeFeature flags
Section titled “Feature flags”Lychee supports several feature flags:
native-tlsenables the platform-native TLS crate native-tls.vendored-opensslcompiles and statically links a copy of OpenSSL. See the corresponding feature of the openssl crate.rustls-tlsenables the alternative TLS crate rustls.email-checkenables checking email addresses using the check-if-email-exists crate. This feature requires the native-tls feature.check_example_domainsallows checking example domains such asexample.com.This feature is useful for testing.
By default, native-tls and email-check are enabled.
Lets get a quick overview of how to use Lychee in your project.
Check All Links In Current Directory
Section titled “Check All Links In Current Directory”The following command recursively checks all links in all supported files inside the current directory.
lychee .This traverses all subdirectories and checks the links in all files which lychee
supports, such as .md, .html, and more.
Check All Links On A Website
Section titled “Check All Links On A Website”lychee https://example.comThis command checks all links on the website https://example.com.
It is not recursive and only checks the links on the given page.
Recursion is currently not supported. You can however download the
sitemap of a website and use that as input.
Check Only Specific Files
Section titled “Check Only Specific Files”lychee README.mdlychee test.html info.txtlychee test.html info.txt https://example.comThis command checks only the links in the given files. It also demonstrates how to check multiple inputs, such as files and URLs in a single command.
Check Links In Directories, But Block All Network Requests
Section titled “Check Links In Directories, But Block All Network Requests”lychee --offline path/to/directoryThis will only check the links in the files in the given directory and not make any network requests. It is helpful for a quick local “linting” of files.
Check Links In A Remote File
Section titled “Check Links In A Remote File”lychee https://raw.githubusercontent.com/lycheeverse/lychee/master/README.mdIf a URL is given as input and it ends with a file extension other than .html,
lychee respects the file extension and interprets the file accordingly.
Here, we interpret the file as Markdown.
Check links from stdin
Section titled “Check links from stdin”cat test.md | lychee -echo 'https://example.com' | lychee -You don’t need to put links into a file first. You can also pipe them into lychee directly.
Check Links In Local Files Via Shell Glob
Section titled “Check Links In Local Files Via Shell Glob”lychee 'public/**/*.html'Have many files in the same directory structure you want to check? You don’t need to list them all. Just use a shell glob!
The above command checks all .html files in the public directory and its
subdirectories.
Advanced Globbing And ~ Expansion
Section titled “Advanced Globbing And ~ Expansion”lychee '~/projects/big_project/\*_/README._'This command checks all README files inside the big_project directory with
files ending in any file extension.
The ~ gets expanded to your home directory.
Ignore Case When Globbing And Check Result For Each Link
Section titled “Ignore Case When Globbing And Check Result For Each Link”lychee --glob-ignore-case --verbose '~/projects/\*_/[r]eadme._'In this command, we ignore the case when globbing, so it matches
~/projects/my_project_/readme.md~/projects/cool_app_/README.txt~/projects/website_/readme.rst~/projects/rust_game_/README~/projects/python_script_/Readme.markdown
Check Links From Epub File
Section titled “Check Links From Epub File”If you have atool installed, you can check links inside .epub files as well!
acat -F zip {file.epub} "_.xhtml" "_.html" | lychee -GitHub Action
Section titled “GitHub Action”Lychee is also available as a GitHub Action.