Skip to content
Coding Script or NotebookGitHubFree

Static Site Link Checks: Stop Broken Internal Links at Build Time (Hugo, Astro, Next.js and More)

ForInternal linkingSite migrations

By Lazarina Stoy· Updated 5 Dec 2026

Rename a post on a static site and every link to its old URL breaks, usually without a warning. In my tests, Hugo, Astro and Eleventy all built a page with a link to a missing page and finished cleanly. This free folder makes a broken internal link fail the build or the pull request instead: the native setting for each generator where one exists, and a tested lychee check of the built HTML everywhere else.

The build is the cheapest moment to catch a broken link: every page is there, the HTML is exactly what readers and crawlers will receive, and a failed check costs one fix before anything goes live. The offline check runs in milliseconds and makes no network requests.

Who it’s for

Anyone who publishes with Hugo, Astro (with or without Starlight), Eleventy, Next.js, Gatsby, Docusaurus or MkDocs and wants internal links checked automatically, before readers or crawlers hit a 404. Most of it is copy and paste; the workflow needs a GitHub repository.

How to use it

  1. Find your generator in the README table and copy its setting: the Hugo render hook, the Starlight plugin line, the Docusaurus options or the MkDocs strict and validation block.
  2. Install lychee, build your site, and run scripts/check-built-site.sh on the output folder. Try it on the included fixture first: it has two broken links on purpose.
  3. Copy lychee.toml to your repository and workflows/link-check.yml to .github/workflows/, then change the output folder and build command.
  4. Optional: add the weekly external-link workflow, which opens an issue instead of blocking merges.

What you get

  • A Hugo link render hook that fails the build on unresolved Markdown links, which Hugo’s built-in hook passes through silently
  • Tested settings for Starlight, Next.js (typedRoutes), Docusaurus and MkDocs, with what each one does and doesn’t catch
  • A lychee config for offline internal-link and #fragment checks, a one-command script and a broken-link fixture
  • GitHub Actions workflows: internal links on every pull request, external links weekly
  • A linkinator config with a skip pattern that works on linkinator 8, and a note on the common pattern that silently checks nothing
  • A README table of what was tested, on which version, and what happened

Limits

Offline checks cover internal links only. Links added by JavaScript after the page loads aren’t in the built HTML, so no file-based checker sees them. Gatsby and the workflows themselves weren’t run in testing; the same lychee version and arguments were tested locally. Everything here is free and open source.

Read the full write-up in stop broken internal links at build time. The course AI-powered Internal Linking Audit and Automation covers shipping links on headless and static sites end to end in Lesson 5.7.

What’s included

  • Tested settings for 7 generators, with what each one catches on its own
  • Hugo render hook that fails the build on broken Markdown links
  • lychee config for offline internal link and #fragment checks, plus a one-command script
  • GitHub Actions: internal links on every pull request, external links weekly
  • linkinator config with a skip pattern that actually checks links on linkinator 8