Skip to content

feat: Add CI workflow to detect broken internal links#963

Merged
bobbyonmagic merged 1 commit intomainfrom
feature/broken-link-checker-845
Mar 1, 2026
Merged

feat: Add CI workflow to detect broken internal links#963
bobbyonmagic merged 1 commit intomainfrom
feature/broken-link-checker-845

Conversation

@bobbyonmagic
Copy link
Collaborator

Fixes #845

Changes:

  • Created scripts/check-broken-links.ts TypeScript script to scan static build
  • Scans all HTML files in out/ directory for internal links
  • Validates each internal link resolves to an existing file
  • Reports broken links grouped by URL with example files
  • Added GitHub workflow .github/workflows/check-links.yml to run on PRs and main branch pushes
  • Added check-links npm script: pnpm check-links
  • Uses jsdom to parse HTML and extract links

How it works:

  1. Builds the static site with pnpm build
  2. Scans all .html files in the out/ directory
  3. Extracts all internal links (starting with /)
  4. Validates each link resolves to:
    • {path}/index.html
    • {path}.html
    • {path} (direct file)
  5. Reports any broken links and fails the CI workflow

Testing:

  • ✅ All 4,551 tests passing
  • Script will run in CI workflow to validate builds before deployment

This helps catch broken navigation early and prevents regressions before deploy.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Mar 1, 2026

Deploying devops-daily with  Cloudflare Pages  Cloudflare Pages

Latest commit: 03b638b
Status: ✅  Deploy successful!
Preview URL: https://bd8656da.devops-daily.pages.dev
Branch Preview URL: https://feature-broken-link-checker.devops-daily.pages.dev

View logs

- Created check-broken-links.ts script to scan static build
- Scans all HTML files in out/ directory
- Validates internal links (href starting with /)
- Reports broken links grouped by URL
- Added GitHub workflow to run on PRs and main pushes
- Added npm script: pnpm check-links
- Installed jsdom and @types/jsdom as devDependencies
- Removed unused BASE_URL constant

Fixes #845
@bobbyonmagic bobbyonmagic force-pushed the feature/broken-link-checker-845 branch from e4be2b4 to 03b638b Compare March 1, 2026 08:59
@bobbyonmagic bobbyonmagic merged commit 12a48d2 into main Mar 1, 2026
3 of 4 checks passed
@bobbyonmagic bobbyonmagic deleted the feature/broken-link-checker-845 branch March 1, 2026 09:53
bobbyonmagic added a commit that referenced this pull request Mar 1, 2026
bobbyonmagic added a commit that referenced this pull request Mar 1, 2026
This undoes the direct commit to main (e2d348c) and restores the merged state.
Changes should go through PR review instead of direct commits to main.
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.

CI: Detect broken internal links (404s) in static Next.js site

1 participant