Project structure

View as Markdown

This page provides an overview of the file and folder structure of a Fern Docs project. The following structure is recommended for organizing your documentation content, but is customizable to fit your needs.

Top-level folders

fern
pages# MDX files
assets# Images or videos
docs.yml# Defines navigation, theme, and hosting
openapi# Or definition/ for the Fern Definition
generators.yml# References spec, configures SDKs
fern.config.json# Organization name and CLI version

A Fern Docs project has the following top-level folders:

  • pages: Contains the Markdown (MDX) files that make up your documentation.
  • assets: Contains any images or videos used in your documentation.
  • docs.yml: Defines the navigation, theme, and hosting details of your documentation.
  • openapi or definition/: Contains your API specification files (if you have an API Reference section).
  • generators.yml: Required for OpenAPI to reference your spec location. Also used to configure SDK generation. Not required for Fern Definition docs-only projects.
  • fern.config.json: The configuration file specifying your organization name and CLI version.

Pages folder

The pages folder contains the Markdown (MDX) files that make up your documentation. Each MDX file represents a page in your documentation.

pages
introduction
quickstart.mdx
project-structure.mdx
showcase.mdx
building-your-docs
navigation
configuration.mdx

The pages folder is organized into subfolders based on the sections of your documentation. Each subfolder contains the MDX files for the pages in that section.

Assets folder

The assets folder contains any images or videos used in your documentation. You can reference these assets in your MDX files using relative paths.

assets
favicon.ico
product-screenshot.svg
demo-video.mp4
logo-dark-mode.png
logo-light-mode.png

docs.yml

The docs.yml file is the heart of your Fern documentation site. This configuration file controls your documentation’s navigation structure, visual design, site functionality, and hosting settings.

For complete configuration options, see the docs.yml reference.

fern/docs.yml of this website
1instances:
2 - url: fern.docs.buildwithfern.com/learn
3 custom-domain: buildwithfern.com/learn
4
5navigation:
6 - section: Introduction
7 layout:
8 - page: QuickStart
9 path: pages/introduction/quickstart.mdx
10 - page: Project Structure
11 path: pages/introduction/project-structure.mdx
12 - page: Showcase
13 path: pages/introduction/showcase.mdx
14
15navbar-links:
16 - type: filled
17 text: Book a demo
18 url: https://buildwithfern.com/contact
19
20logo:
21 light: ./images/logo-primary.svg
22 dark: ./images/logo-white.svg
23
24colors:
25 accent-primary:
26 dark: "#ADFF8C"
27 light: "#209d63"
28
29favicon: ./images/favicon.ico
30
31title: Fern's Documentation

API definitions and generators.yml

To generate API Reference documentation, you need to provide your API definition. How you do this depends on your format:

  • OpenAPI/AsyncAPI: Always requires a generators.yml file with an api.specs section. You can optionally add a groups section for SDK generation.
  • Fern Definition: Auto-detected when you have a definition/ directory. Only add generators.yml if you’re generating SDKs.
Using Fern for both API Reference docs and SDKs? You’ll use docs.yml for your documentation settings and generators.yml to configure SDK code snippets in your API Reference.

The openapi folder contains your OpenAPI Specification file. Fern supports either YAML or JSON format.

You must also create a generators.yml file that references your spec:

generators.yml
1api:
2 specs:
3 - openapi: ../openapi/openapi.json

In addition to your specification file, you can optionally add an overrides file for additional customizations.

openapi
openapi.yaml# Or openapi.json
overrides.yaml# Optional

To see this in practice, check out Fluidstack’s Fern configuration.

The definition folder contains the Fern Definition YAML files used to generate the API Reference section. Fern automatically detects this directory, so no generators.yml is needed for API Reference documentation.

You can optionally add an overrides file for additional customizations.

definition
pets.yaml
owners.yaml
stores.yaml
overrides.yaml# Optional
api.yaml

See an example.

Organize multiple APIs into separate folders. You can mix OpenAPI and Fern Definition formats:

apis
admin-api
openapi.json
generators.yml# Required for OpenAPI
overrides.yaml# Optional
user-api
definition# Auto-detected for Fern Definition
api.yml
overrides.yaml# Optional

Reference each API in docs.yml using api-name that matches the folder name. To see this in practice, check out Vapi’s Fern configuration.

fern.config.json

The fern.config.json file stores your organization name and the Fern CLI version. Pinning the version provides deterministic builds.

fern.config.json
1{
2 "organization": "plant-catalog",
3 "version": "2.8.2"
4}

When working with a locally installed CLI, set version to "*". See Install Fern CLI locally for details.