For example, you could create a snippet that contains your company's copyright information. Wherever you want the copyright to appear, instead of typing it out again and again, you would use the snippet's merge code in its place.
When the page displays, the snippet merge code is replaced with the snippet's content. When you need to update your copyright information, you can edit and update the snippet content, and the changes will be automatically reflected wherever the snippet was used.
Text within snippets is not indexed for search.
If you have a chunk of content that you'd like to reuse but that also makes sense as a stand-alone article, consider using topic articles instead!
To create a snippet:
- Go to Library > Snippets.
- Click the + Create New Snippet button.
- Give your snippet a name. This is how the name will appear in the Snippet Library and in snippet look-ups. The Merge Code Name will auto-generate from the Snippet Name, but you can edit it if you'd like to.
- Give your snippet a Description. This will help describe what your snippet does to other users (and may help remind you if you forget!) Here, we've added a name and description for a copyright statement.
- If your snippet is used to display text (as our copyright is), type and format the text you want to display directly in the WYSIWYG.
- For code-based snippets, click the dropdown next to Snippet Content to select the Code Editor, and add your code there.
- Once you've finished formatting your snippet, click the Create button.
Your snippet will now display in the Snippet Library, as well as in the look-up field when someone tries to Insert Snippet into an article.
You can add snippets to:
- Individual articles
- Custom HTML (adding snippets to Custom HTML > Body is great for adding footer content; you can add snippets to Custom HTML > Article to add them to all articles)
To add a snippet, you will need to add its Merge Code Value--this is a value in double curly brackets, with snippet.MergeCodeName after it. For individual articles, you can use the Add Snippet button to add a snippet:
This will open a pop-up where you can search for your snippet. Type the name and click on the suggestion that matches it. This will display the Description and Snippet body so you can be sure you've selected the correct snippet. Once you're sure you've selected the correct snippet, click Insert Snippet.
You should now see your merge code value in the article, like this:
Anyone viewing the knowledge base will see the body of the snippet (if it's text) or will see the results of the code in it. For example:
Copyright © 2015 – 2019 Silly Moose, LLC. All rights reserved.
These documents are a static export of a dynamic knowledge base. For the most up-to-date information, please see our knowledge base.
All created snippets are stored in the Snippet Library. To access this library, go to Library > Snippets.
Within the Snippet Library, you can:
- Create new snippets
- Search for existing snippets using words in the snippet title and description
- Click on any snippet to open it in edit mode
- Delete a snippet by clicking the X in the upper right corner
Note: The Snippet Library is sorted alphabetically and is case sensitive. This means that all snippets beginning with upper case letters will appear first, in alphabetical order, followed by all snippets beginning with lower case letters, also in alphabetical order.
There are a number of great use cases for snippets:
- Footers or other statements that need to be used a lot of places, such as confidentiality statements
- Brand names or terms that may change frequently: make a snippet for that term, only reference the snippet instead of the full term in all your documentation. When the term needs updating, update only the snippet and all your documentation is updated!
- Specialized sections for articles, such as Article Table of Contents
- Code to handle unusual formatting, or to provide a set of styles for individual articles that differs from your general knowledge base styles.
When you're viewing a snippet in the editor, you'll see a References section in the lower right:
These references capture articles or custom content categories that you've added the snippet merge code to, to help you audit where the snippet is used. These references are generated when you save an article or custom content category with a snippet's merge code in it somewhere.
You can click the View details... link to open a pop-up showing a full list of the articles and custom content categories that reference this snippet:
Note: Only articles and custom content categories which have been created or updated since 11 November 2020 will show in the references list. If you have older content with the snippet, try resaving the article or custom content category with an extra blank line at the end of the content. This is enough of a change to trigger the reference save, and then you can re-save without the blank line. For existing customers, see New feature: Snippet references for more details on this change.