Redirects map old URLs to new ones so inbound links and search rankings survive when pages move, change slugs, or are deleted.
Configure redirects in docs.yml using exact paths or regex patterns, pointing at either internal paths or external URLs.
If your docs are hosted on a subpath (like buildwithfern.com/learn), include the subpath in both the source and destination paths.
Parameters suffixed with an asterisk (*) match zero or more path segments, capturing everything that follows in the URL. Use this when redirecting entire folder structures while preserving nested paths.
Redirects are evaluated top-to-bottom and the first match wins:
A broader pattern listed before a more specific one prevents the specific rule from ever matching.
The relative path you want to redirect from (e.g., /old-path). Must be a relative path, not an absolute URL. Must not include search parameters (e.g., ?key=value).
The path you want to route to. Can be an internal path (/new-path) or an external URL (https://example.com). External URLs must include the full address, including https.
By default, uses the 308 status code to instructs clients and search engines to cache the redirect forever. Set to false only if you need a temporary redirect using the 307 status code, which won’t be cached.
For optimal site performance, only add redirects when necessary. Avoid using redirects for behavior that Fern already handles automatically, such as 404 handling and version routing.
Don’t create redirects to send broken links to your homepage:
Instead, enable automatic homepage redirects in your docs.yml to send broken links to your homepage rather than showing a 404 page:
If you have versions configured, your default version uses unversioned paths (/docs/getting-started), while other versions use versioned paths (/docs/v2/getting-started). Fern automatically handles version routing by redirecting broken versioned links to the default version and managing canonical URLs.
Avoid redirecting from unversioned to versioned URLs:
Manually overriding the default versioning behavior can lead to unexpected redirect patterns.
If you frequently need to redirect from the default version to another version, consider changing which version is set as default in your versions configuration.
The missing-redirects rule, run by fern check, compares the navigation tree built from your local YAML against the most recently published state of your site and flags previously-published URLs that no longer resolve and aren’t covered by an entry in redirects:. This catches pages you’ve moved or removed before they start returning 404s for existing inbound links.
Tune severity with the missing-redirects rule in docs.yml.