Writing Content
Reusable Snippets
Reusable, custom snippets to keep content in sync
One of the core principles of software development is DRY (Don’t Repeat Yourself). This is a principle that we should apply to our documentation as well. If you find yourself repeating the same content in multiple places, you should consider creating a custom snippet to keep your content in sync.
Creating and using a custom snippet
- Create a new file in the
_snippets
directory. - Construct your snippet content - it can be a component or a chunk of text.
_snippets/my-snippet.mdx
## My Snippet
This is my snippet.
<Info>I want to use this content in more than one place in my docs.</Info>
- Navigate to the file where you want to use the snippet.
- Add the snippet to the file using the following syntax:
destination-file.mdx
<Snippet file="my-snippet.mdx" />
You do not need to prepend the “_snippets” directory to the file name and you do not need to import the snippet.
Was this page helpful?