check command is the main command in Linkspector. It scans your documentation files for hyperlinks and validates them according to your configuration.
Usage
What It Does
When you runlinkspector check, the tool:
- Loads configuration from
.linkspector.yml(or a custom config file) - Scans files based on your configured directories and file extensions
- Extracts all hyperlinks from Markdown and AsciiDoc files
- Validates each link:
- HTTP/HTTPS links are checked for availability
- File links are verified to exist
- Header anchors are validated
- Email links are skipped
- Reports broken or unreachable links
- Exits with code 0 if all links are valid, or code 1 if any links fail
Basic Example
.linkspector.yml configuration file in your current directory.
Output Formats
Default Output (Console)
By default, Linkspector displays results in a human-readable format with a spinner showing progress:JSON Output
Use the-j or --json flag to output results in Reviewdog Diagnostic Format (RDJSON):
Statistics Output
Use the-s or --showstat flag to display detailed statistics:
Using a Custom Configuration File
- You have multiple configuration files for different environments
- Your config file is not in the current directory
- You want to test different configurations
Combining Options
Check with Statistics
Check with JSON Output
Error Handling
Configuration File Not Found
If no configuration file is found, Linkspector uses default settings:- Directories:
['.'](current directory) - File extensions:
['md'] - Use gitignore:
true
Invalid Configuration
If your configuration file is invalid:Git Not Installed (when using modifiedFilesOnly)
If you enablemodifiedFilesOnly but Git is not installed:
No Modified Files
When usingmodifiedFilesOnly: true and no files have been modified:
Exit Codes
- 0: All links are valid
- 1: One or more links failed or an error occurred
Environment Variables
You can use environment variables in your configuration file. Linkspector will replace placeholders like${VARIABLE_NAME} with the corresponding environment variable values.
Example: