Files to Check
Thefiles section specifies individual files that Linkspector should check for broken links.
You must include either
files or dirs (or both) in your configuration.Configuration
Behavior
- Provide the full or relative paths to the files you want to check
- Paths are relative to the current working directory
- Supports Markdown (
.md), AsciiDoc (.adoc), and other markup files
Directories to Search
Thedirs section lists directories where Linkspector should search for files to check.
Configuration
Behavior
- Linkspector recursively searches all subdirectories
- Use
./or.to check the current directory - Paths are relative to the current working directory
- All supported markup files in these directories will be checked
You can use both
files and dirs together in the same configuration to check specific files and entire directories.Excluded Files
TheexcludedFiles section allows you to specify files that should be excluded from link checking.
Configuration
Behavior
- Files listed here will be skipped even if they’re in a directory specified in
dirs - Useful for excluding drafts, templates, or files with known issues
- Paths are relative to the current working directory
Example Use Case
./docs except template.md and draft-feature.md.
Excluded Directories
TheexcludedDirs section lets you specify directories that should be excluded from link checking.
Configuration
Behavior
- Directories listed here and all their contents will be skipped
- Useful for excluding third-party code, build outputs, or archived content
- Paths are relative to the current working directory
Example Use Case
node_modules, dist, and .git directories.
Use GitIgnore
TheuseGitIgnore option tells Linkspector to respect the rules defined in your .gitignore file.
Configuration
Behavior
- When set to
true, Linkspector automatically excludes files and directories listed in.gitignore - When set to
false,.gitignorerules are not applied - Default value:
true(in the default configuration)
Example
If your.gitignore contains:
node_modules/, .env, and dist/ without you needing to add them to excludedDirs or excludedFiles.
Using
useGitIgnore: true is recommended to avoid checking generated files and dependencies.Check Modified Files Only
ThemodifiedFilesOnly option restricts link checking to files that have been modified in the last git commit.
Configuration
Behavior
- When set to
true, Linkspector usesgitto find modified files and only checks those - Only files changed in the last commit are checked
- Useful in CI/CD pipelines to check only changed content
- Requires
gitto be installed and available in your system path
Example Use Case
In a CI/CD pipeline where you only want to check links in files that were modified in the current pull request:If no modified files are found in the list of files to check, Linkspector will skip link checking and exit with a message indicating no modified files were edited.
Complete Example
Here’s a comprehensive example combining all file and directory options:- Checks
README.mdandCONTRIBUTING.mdexplicitly - Searches the
docsandcontentdirectories - Excludes specific template and draft files
- Excludes archive and old content directories
- Respects
.gitignorerules - Checks all files (not just modified ones)