Skip to content

Commit b513444

Browse files
Add docs for fern docs link check CLI command
(#5514) Co-authored-by: fern-api[bot] <115122769+fern-api[bot]@users.noreply.github.com> Co-authored-by: Devin Logan <devinannlogan@gmail.com>
1 parent 0aeaf19 commit b513444

3 files changed

Lines changed: 96 additions & 3 deletions

File tree

fern/products/cli-api-reference/pages/commands.mdx

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ hideOnThisPage: true
2929
| [`fern docs md check`](#fern-docs-md-check) | Validate MDX syntax in documentation files |
3030
| [`fern docs theme export`](#fern-docs-theme-export) | Export theme-eligible fields from `docs.yml` into a standalone directory |
3131
| [`fern docs theme upload`](#fern-docs-theme-upload) | Upload a theme to Fern's registry |
32+
| [`fern docs link check`](#fern-docs-link-check) | Check for broken links on a live documentation site |
3233
| [`fern docs theme list`](#fern-docs-theme-list) | List all themes for your organization |
3334

3435
## SDK generation commands
@@ -281,8 +282,6 @@ hideOnThisPage: true
281282
Use `fern check` to validate your API definition and Fern configuration, including [`fern.config.json`](/learn/sdks/overview/project-structure#fernconfigjson), `generators.yml`, and `docs.yml`. It checks for broken links, invalid API examples, configuration errors, and more. When all checks pass, the command produces no output.
282283

283284
Most `fern check` rules — including [`broken-links`](/learn/docs/configuration/site-level-settings#check-configuration) — validate against the navigation tree built from your **local** config and do not crawl your live deployed site or follow external URLs. The exception is the [`missing-redirects` rule](/learn/docs/seo/redirects#catching-missing-redirects), which compares your local navigation against the previously published state and therefore requires `fern login` or `FERN_TOKEN`.
284-
285-
To check links on a published site, use the link checker in the [Fern Dashboard](https://dashboard.buildwithfern.com/) instead. When all checks pass, the command produces no output.
286285

287286
<CodeBlock title="terminal">
288287
```bash
@@ -300,6 +299,10 @@ hideOnThisPage: true
300299
missing-redirects: error
301300
```
302301

302+
<Info>
303+
To check links on a published site, use [`fern docs link check`](#fern-docs-link-check) or the link checker in the [Fern Dashboard](https://dashboard.buildwithfern.com/) instead.
304+
</Info>
305+
303306
### api
304307

305308
Use `--api <api>` to specify which API you'd like to check.
@@ -466,6 +469,73 @@ hideOnThisPage: true
466469

467470
</Accordion>
468471

472+
<Accordion title="fern docs link check">
473+
474+
Use `fern docs link check` to scan a live documentation site for broken links. The command crawls the published site, checks every link, and reports broken (404) and blocked (403) URLs along with their source pages.
475+
476+
<CodeBlock title="terminal">
477+
```bash
478+
fern docs link check [--url <url>] [--output <format>]
479+
```
480+
</CodeBlock>
481+
482+
<Info>
483+
Unlike the [`broken-links` rule](#fern-check) in `fern check`, which validates only internal links in your local YAML navigation tree, `fern docs link check` checks all links — internal and external — on your live deployed site.
484+
</Info>
485+
486+
By default, the command auto-detects your docs URL from the `instances` in `docs.yml`. When all links are valid, the command exits with a success message.
487+
488+
The command first scrapes every page on the site, then checks each link it finds. When broken links are found, the output includes a summary and a grouped list of broken URLs with status codes and source file paths.
489+
490+
```plaintext
491+
◆ Checking links on your-org.docs.buildwithfern.com...
492+
493+
Scraping pages [████████████████████] 100% | 42/42
494+
Checking links [████████████████████] 100% | 240/240
495+
496+
Finished in 2 minutes, 23 seconds
497+
498+
Summary
499+
Pages scanned 42
500+
Links checked 240
501+
✓ Working 228
502+
✗ Broken 8 (external)
503+
⚠ Blocked 4
504+
505+
─────────────────────────────────────
506+
507+
External Broken Links (8)
508+
509+
✗ https://example.com/removed-page → 404
510+
fern/pages/quickstart.mdx
511+
fern/pages/overview.mdx
512+
513+
✗ https://example.com/old-endpoint → 404
514+
fern/pages/integrations.mdx
515+
```
516+
517+
### url
518+
519+
Use `--url` to specify which docs site to check. This is useful when you have multiple instances or want to check a preview deployment.
520+
521+
```bash
522+
fern docs link check --url https://your-org.docs.buildwithfern.com
523+
```
524+
525+
### output
526+
527+
Use `--output` to control the output format. Supported values are `text` (default), `json`, and `csv`.
528+
529+
```bash
530+
# JSON output for programmatic use
531+
fern docs link check --output json
532+
533+
# CSV output for spreadsheets or reporting
534+
fern docs link check --output csv
535+
```
536+
537+
</Accordion>
538+
469539
<Accordion title="fern docs md check">
470540

471541
Use `fern docs md check` to validate MDX syntax across all documentation pages referenced in your navigation configuration, including `docs.yml`, versioned configuration files, and product-specific YAML files.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
tags: ["configuration"]
3+
---
4+
5+
## CLI link checker
6+
7+
You can now check for broken links on your live documentation site directly from the Fern CLI with `fern docs link check`. The command scrapes every page on your published site, checks all internal and external links, and reports broken (404) and blocked (403) URLs along with the source pages where they appear.
8+
9+
```bash
10+
fern docs link check --url https://buildwithfern.com/learn
11+
fern docs link check --url https://elevenlabs.io/docs
12+
```
13+
14+
This complements the existing [`broken-links` rule](/learn/docs/configuration/site-level-settings#check-configuration) in `fern check`, which validates internal links against your local YAML navigation tree. Use `fern docs link check` after publishing to catch live 404s and broken external URLs that local validation can't detect.
15+
16+
<Button intent="none" outlined rightIcon="arrow-right" href="/learn/cli-api-reference/cli-reference/commands#fern-docs-link-check">Read the docs</Button>

fern/products/docs/pages/component-library/writing-content/markdown-basics.mdx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,14 @@ In [versioned docs](/learn/docs/configuration/versions), the same path lands on
7474

7575
### Validating links
7676

77-
The [`broken-links` rule](/learn/docs/configuration/site-level-settings#check-configuration) — run by [`fern check`](/learn/cli-api-reference/cli-reference/commands#fern-check), including during `fern docs dev` — validates each internal link against the navigation tree built from your **local** YAML. It does not crawl your deployed site or follow external URLs. To check links on a published site, use the [Fern Dashboard](https://dashboard.buildwithfern.com/).
77+
Fern provides two ways to catch broken links. The [`broken-links` rule](/learn/docs/configuration/site-level-settings#check-configuration) — run by [`fern check`](/learn/cli-api-reference/cli-reference/commands#fern-check), including during `fern docs dev` — validates each internal link against the navigation tree built from your **local** YAML. To check links on a published site, use [`fern docs link check`](/learn/cli-api-reference/cli-reference/commands#fern-docs-link-check) or the [Fern Dashboard](https://dashboard.buildwithfern.com/).
78+
79+
| | `fern check` broken-links rule | `fern docs link check` |
80+
|---|---|---|
81+
| What it checks | Internal links in your **local** YAML navigation tree | All links on your **live deployed** site |
82+
| External links | Not checked | Checked |
83+
| Requires a published site | No | Yes |
84+
| When to use | In CI, before publishing | After publishing, to catch live 404s and broken external URLs |
7885

7986
### API link syntax
8087

0 commit comments

Comments
 (0)