Writing Content
Reusable Snippets
Reusable, custom snippets to keep content in sync
Reusable snippets help you maintain consistent content across your documentation by letting you write content once and reuse it in multiple places. This follows the DRY (Don’t Repeat Yourself) principle.
Creating a Snippet
All snippets must be created in the snippets
directory. These files won’t be rendered as standalone pages.
Snippets are only accessible from the snippets
directory. To use a snippet as a page, import it into another file and use it as a component.
Basic Snippet
- Create your snippet file with reusable content:
snippets/my-snippet.mdx
- Use the snippet in your pages:
destination-file.mdx
Variables and Components
You can also create reusable variables and components:
snippets/variables.mdx
Use them in your pages:
destination-file.mdx
Client-Side Content
For client-side rendering, check for the document
object:
snippets/client-component.mdx
Was this page helpful?