Fumadocs

Validate Links

Fail the build on broken links.

Setup

linkValidationPlugin() checks links in your pages with next-validate-link when you build, and fails the build on a broken one.

npm i next-validate-link
src/fumadocs.config.ts
import { defineConfig } from '@fumadocs/astro/config';
import { linkValidationPlugin } from '@fumadocs/astro/plugins/link-validation'; 
import { source } from './lib/source';

export default defineConfig({
  source,
  plugins: [linkValidationPlugin()], 
});

Links can point to your pages and their headings, plugin routes, Astro pages and public/ files:

[Fumadocs] broken links:
In "content/docs/index.mdx:12:1": link "/docs/missing" not-found

Options

It takes the validateFiles() options, like whitelist for links to skip and checkExternal for absolute URLs:

src/fumadocs.config.ts
linkValidationPlugin({
  whitelist: (href) => href.startsWith('/api/'),
  checkExternal: true,
});

href attributes of Card are checked by default, change the components with markdown.components.

How is this guide?

Last updated on