Reusable snippets
Keep your documentation DRY (Don’t Repeat Yourself) with single sourcing: define a reusable Markdown snippet once, and then reference it in multiple places. This way, you only need to update the snippet in one place to keep all references in sync.
Reusable snippets work well for constants (API limits, subscription prices, version numbers), repeated warnings or notes, and standardized formatting blocks.
Create file structure
Create a folder called snippets anywhere in your fern project. Inside the snippets folder, create a new Markdown file for each snippet you want to define.
Add parameters to snippets (optional)
To make snippets more flexible, you can use parameters (also called variables). Parameters use the {{parameterName}} syntax and can be placed anywhere in your snippet content.
You can then pass different values to these parameters each time you use the snippet.
Use a snippet
To use a snippet in your documentation, reference it by its file path (including the .mdx extension). If you used parameters (variables) in your snippet, pass values for each parameter:
Markdown
Preview
File paths
The src path is an absolute path that takes the fern folder as the root. The path is the same no matter which page you’re referencing it from: