bezier-curveAutomated Link Checking

Guide to automated link validation and CI/CD integration

Automated validation of documentation links to prevent broken references


Overview

Automated link checking ensures all internal and external links in documentation remain valid, preventing broken links from reaching users. The NeurosLink AI documentation uses markdown-link-check for automated validation.

Benefits

  • Prevent broken links: Catch broken links before deployment

  • Automated validation: Run checks on every commit

  • Internal link validation: Verify cross-references between docs

  • External link monitoring: Check third-party URLs periodically

  • CI/CD integration: Fail builds on broken links


Quick Start

# From docs/improve-docs directory
chmod +x scripts/check-links.sh
./scripts/check-links.sh docs

Output:

Install Dependencies


Configuration

The script uses /tmp/mlc_config.json with default settings. To customize, create .markdown-link-check.json:

Configuration Options

Option
Description
Default

timeout

HTTP request timeout

10s

retryOn429

Retry on rate limit errors

true

retryCount

Number of retries

3

aliveStatusCodes

Valid HTTP status codes

[200, 206, ...]

ignorePatterns

URLs to skip checking

[]


CI/CD Integration

GitHub Actions Workflow

Create .github/workflows/link-check.yml:

Pre-commit Hook

Add to .husky/pre-commit or .git/hooks/pre-commit:

Make executable:


Usage Patterns

Check Specific File

Check All Docs

Check with Custom Config

Quiet Mode (Only Show Errors)

Verbose Mode (Debug)


Common Issues

Cause: Some sites block automated requests or have aggressive rate limiting.

Solution: Add to ignore patterns:

Or add to alive status codes:

Issue 2: Slow Checks

Cause: External link checking can be slow.

Solution 1: Skip external links for local development:

Solution 2: Use faster internal-only checker:

Issue 3: Relative Path Issues

Cause: Relative links may not resolve correctly.

Solution: Use replacement patterns:

Cause: markdown-link-check may not validate anchor links (#section).

Solution: Use remark-validate-links:


Advanced Usage

For complex validation needs, create custom scripts:

Run:

For faster checking with many files:


Best Practices

1. Regular Checks

  • On every commit: Check changed files in pre-commit hook

  • On every PR: Full link check in CI/CD

  • Weekly: Scheduled check for external link rot

2. Separate Internal and External

3. Ignore Transient Failures

Some external links may fail intermittently. Retry failed checks:

4. Document Known Issues

For persistent false positives, document in .markdown-link-check.json:


Integration with MkDocs

Add to mkdocs.yml:

Create scripts/check-links-hook.py:



Additional Resources

Last updated

Was this helpful?