跳到导航

Profiles

Publish one set of pages as several editions
以 Markdown 格式查看

A profile is a named set of values, such as a product name or CLI command. Write ${NAME} in a page, and Fern swaps in the value from the profile. Give each product, version, or tab its own profile, and one page shows the right values in every edition, with no copies to maintain.

Define profiles

Add profiles to docs.yml, then select one with profile:

docs.yml
profiles:
community:
vars:
PRODUCT: Acme
CLI: acme
enterprise:
vars:
PRODUCT: Acme Enterprise
CLI: acme-ent
profile: community
products:
- display-name: Community
slug: community
path: ./products/community.yml
- display-name: Enterprise
slug: enterprise
path: ./products/enterprise.yml
profile: enterprise

vars also accepts a path to a YAML file, or a list of paths. Paths are relative to docs.yml, and each file has a top-level vars map:

profiles:
enterprise:
vars:
- ./vars/common.yml
- ./vars/enterprise.yml

A name defined in two files fails the build. Vars files are committed with your docs, so don’t store secrets in them.

Use placeholders

Write the page once:

install.mdx
---
title: Install ${PRODUCT}
---
Run `${CLI} install`.

When both product files list install.mdx, Fern builds one page per product, each at its own URL. Under Enterprise, the page reads “Install Acme Enterprise” and “Run acme-ent install”.

Values fill page content and frontmatter, navigation titles, navbar links, the announcement banner, and footer text. Search, Markdown output, and llms.txt get the same filled text. Endpoint and webhook descriptions from an API definition aren’t filled.

Which profile applies

Set profile at the top level of docs.yml or on a product, version, tab, tab variant, section, or page. The closest one to a page wins: page, then section, tab variant, tab, version, product, and site.

A closer profile replaces the outer one entirely, including names it doesn’t define. fern check reports a profile that names no entry in profiles.

Escapes and missing values

  • To show a literal ${NAME}, write \$\{NAME\}.
  • A placeholder whose name isn’t in the applied profile stays as written.
  • With substitute-env-vars on, Fern fills a missing name from the environment variable with the same name. This also covers pages with no profile.