Skip to content

Conversation

@danielle-teagarden
Copy link

Add automated broken link checker using Lychee

Description

This PR implements automated broken link checking as discussed in issue #1521. It uses Lychee, the tool recommended in the issue discussion.

Implementation Details

Files Added

  1. .github/workflows/broken-links.yml - GitHub Action workflow that:

    • Runs monthly (1st of each month at 9 AM UTC)
    • Can be triggered manually via workflow_dispatch
    • Builds the site before checking links
    • Creates a single issue if broken links are found
  2. .lycheeignore - Configuration file to reduce false positives by excluding:

    • Social media URLs (often block automated tools)
    • Authentication-required pages
    • Local development URLs
    • Known problematic domains

How It Works

  1. Build First: The workflow builds the site to check actual output, not source files
  2. Comprehensive Checking: Checks both internal and external links
  3. Smart Retries: Retries failed requests up to 3 times with 20-second timeout
  4. Single Issue: Creates one consolidated issue instead of multiple notifications
  5. Appropriate Labels: Adds bug, help wanted, and content labels

Configuration Choices

Based on the discussion in #1521:

  • ✅ Uses Lychee as suggested by @p2635
  • ✅ Runs periodically (monthly) rather than on every commit
  • ✅ Creates a single issue to avoid notification spam
  • ✅ Includes common exclusions to reduce false positives

Testing

The workflow can be tested immediately after merging by:

  1. Going to Actions tab
  2. Selecting "Check for Broken Links" workflow
  3. Clicking "Run workflow"

Questions for Review

  1. Frequency: Currently set to monthly. Would you prefer a different schedule?
  2. Assignees: Currently assigns @ericwbailey and @scottohara. Should this be changed?
  3. Exclusions: Are there other domains that commonly give false positives?
  4. Issue Title: Currently "Monthly Broken Links Report". Preference for different naming?

Related Issue

Resolves #1521

Additional Notes

  • The action won't fail the workflow even if broken links are found (uses fail: false)
  • The report is in markdown format for easy reading
  • Future enhancements could include caching to speed up checks

- Implements monthly automated link checking as discussed in a11yproject#1521
- Uses Lychee broken link checker via GitHub Actions
- Runs on the 1st of each month at 9 AM UTC
- Can also be triggered manually via workflow_dispatch
- Creates a single GitHub issue when broken links are found
- Includes common exclusions to reduce false positives

The workflow:
1. Builds the site first to check actual output
2. Runs Lychee on the built site
3. Creates an issue with markdown-formatted report if broken links exist
4. Assigns appropriate labels and maintainers

Addresses a11yproject#1521
The A11Y Project uses 'eleventy-build' not 'build' as the npm script
@danielle-teagarden
Copy link
Author

I've tested the workflow and discovered an issue - the build command should be npm run eleventy-build not npm run build (which doesn't exist in package.json). I've pushed a fix to correct this.

The workflow is now properly configured to:

  1. Build the site with the correct command
  2. Run Lychee on the generated _site directory
  3. Create issues only when broken links are found
  4. Run monthly on the 1st at 9 AM UTC

(Sorry for the early pull request; I turned my AI bot loose and it got a bit overzealous & excited to contribute; I'm excited too.)

@SaptakS
Copy link
Member

SaptakS commented Jun 30, 2025

Hi @danielle-teagarden , Thanks for working on this! I haven't taken a close look at it yet, but can you please update the PR to not include the PR-description files and the report.txt? I don't think we need to commit those to the repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Add a broken link checker to the CI/CD pipeline

2 participants