Sharing content using includes and snippets

NOTE

Includes/snippets are not yet enabled by default for all repos because we’re still testing localization effects. Let the SCCM team know if you want to try using includes/snippets in your repo.

Use includes and snippets to share content among multiple articles within a repo. At this time, includes and snippets work only within a repo.

  • Includes are useful for inserting the entire contents of a file (everything after the first # heading) into a different file. Create .md files in the help > _includes folder, and reference them from any article in the repo.
  • Snippets are useful for sharing smaller sections of text. Add these smaller snippets to the markdown.md file in the help > _includes folder.
NOTE

The key difference between a snippet and an include is that an include can have headings. A snippet cannot have headings.

Creating includes

  1. If necessary, create an _includes directory in the help directory.

  2. Create a markdown file in the _includes directory with the content you want to share.

    In this source markdown file, any metadata and the H1 (# Title) is ignored. Everything after the H1 is included when referenced.

  3. On a blank line in the target article, add a reference to the source include file in this format:

    {{$include /help/_includes/legal-blurb.md}}

  4. Commit the content and preview it.

includes flow

NOTE

If your repo is enabled for includes, make sure that you escape any {{ or }} characters in files that do not reference include files.

Creating snippets

For sharing smaller sections of text, you can create a snippets.md file and reference the H2 anchors. Snippets cannot include headings. If you need to include headings in your shared text, use includes.

  1. Create a snippets.md file in the help > _includes directory.

  2. Create a dummy H1 title.

  3. For each shared section, create a Heading 2 with an anchor to be used to reference the snippet. Example:

    ## Premium note {#premium-note}
    
    >[!NOTE]
    >
    >This feature is available as part of the Target Premium solution. It is not available in Target Standard without a Target Premium license.
    
  4. In the target article, add a reference to the snippets.md file in this format:

    {{premium-note}}

  5. Commit the content and preview it.

snippets flow

NOTE

If your repo is enabled for snippets, make sure that you escape any {{ or }} characters in files that do not reference snippets.

On this page