章节、页面和文件夹
章节、页面和文件夹
在 docs.yml 中组织您的侧边栏导航结构
docs.yml 中的 navigation 键定义了您的侧边栏结构。通过组合章节、页面和文件夹来构建它。
添加章节
章节在左侧导航栏中组织您的文档。每个章节都有一个名称和一个 contents 列表,可以包括页面、文件夹或嵌套章节。
章节可以嵌套以创建多级导航层次结构。

要为章节添加概述页面,添加一个指向 .mdx 文件的 path 属性。
添加页面
创建一个 .md 或 .mdx 文件,然后在章节的 contents 中添加一个包含文件路径的 page 条目。
添加文件夹
添加一个指向目录的 folder 条目。Fern 会自动发现所有 .md 和 .mdx 文件并将它们添加到导航中。
对于文件夹中的页面,Fern 自动:
- 将文件名转换为标题和 URL 别名
- 从子目录创建嵌套章节
- 按字母顺序排序页面
- 使用
index.mdx或index.md文件作为章节概述页面(不区分大小写)
文件夹配置选项
使用这些选项自定义文件夹行为:
title
为此文件夹章节显示的标题。如果未提供,则使用文件夹名称。
title-source
确定文件夹内的页面和章节标题如何生成。默认情况下(filename),标题从文件名生成。设置为 frontmatter 以使用每个文件 frontmatter 中的 title 字段(如果未设置则回退到文件名)。此单个文件夹设置会覆盖全局的 settings.folder-title-source 值。
slug
覆盖文件夹自动生成的 URL 别名。
skip-slug
从 URL 路径中省略文件夹,因此页面显示在父级别。
position
在页面 frontmatter 中设置以控制文件夹内的排序。具有 position 的页面首先出现(按数字排序),然后是其余的按字母顺序排列。
隐藏内容
要隐藏页面、文件夹或章节,添加 hidden: true。隐藏的内容(包括文件夹内的所有页面)仍可通过直接 URL 访问,但会从搜索中排除且不会被索引。
可用性
在页面、章节或文件夹上设置可用性徽章。选项有:stable、generally-available、in-development、pre-release、deprecated 或 beta。
页面从其父章节或文件夹继承可用性,除非被以下覆盖:
docs.yml中的单个页面availability设置(如下所示)- 页面 frontmatter 可用性,它优先于所有
docs.yml可用性设置
如果您有不同版本的文档,章节、文件夹和页面可用性应在定义每个版本导航结构的 .yml 文件中设置。
折叠的章节或文件夹
默认情况下,章节和文件夹是展开的且不可折叠。使用 collapsed 属性控制它们在页面加载时在侧边栏中的显示方式。
侧边栏图标
使用 icon 键为章节、页面和文件夹添加图标。
Icons can be in three formats:
- Font Awesome icons: Use icon names like
fa-solid fa-rocket. Pro and Brand Icons from Font Awesome are supported. - Custom image files: Use relative paths to image files (e.g.,
./assets/icons/my-icon.svgor../assets/icons/my-icon.png). Paths are relative to the YAML file where the icon is referenced (e.g.,docs.yml). For example, if you set an icon infern/products/my-product.yml, the path./assets/icon.svgresolves tofern/products/assets/icon.svg. If you set it infern/docs.yml, the same path resolves tofern/assets/icon.svg. - Inline SVG: Provide an SVG string wrapped in quotes (e.g.,
"<svg>...</svg>").
链接
您可以通过以下配置在侧边栏导航中添加指向外部页面的链接:

链接目标
Control where links open with the target property. Available for product, tab, navbar, and page links. For typical documentation sites, links can open in the same tab (_self) or new tab (_blank). For documentation embedded in a dashboard or iframe, links can open in the parent frame (_parent) or topmost frame (_top).