Skip to main content

Using code snippets in your course

Written by Emma Abrahamsson

Use code snippets to add formatted technical content to your course. They help learners read, copy, and reuse code, commands, and other exact text without losing formatting.

What is a code snippet?

A code snippet lets you display formatted code in a monospaced block. It keeps technical content readable and preserves spacing, indentation, and syntax.

Why use code snippets?

Code snippets make technical course content easier to read and reuse. Use them when learners need to copy exact text or inspect how something is structured.

Code snippets are useful when you want to:

  • Display code samples, terminal commands, or preformatted text

  • Teach programming or technical workflows

  • Make text easy for learners to copy

  • Preserve exact syntax, spacing, quotation marks, line breaks, and symbols

  • Separate technical examples from explanatory text

For example, you can use code snippets for JavaScript, Python, SQL, HTML, CSS, API calls, configuration files, command-line instructions, formulas, prompts, and setup instructions.

Use case examples

Teach programming concepts

Use code snippets to show examples in programming languages, such as JavaScript, Python, SQL, HTML, or CSS. This helps learners read the code clearly and understand its structure.

Share setup instructions

Use code snippets for terminal commands, configuration files, or installation steps. This makes it easier for learners to copy the exact text and avoid formatting errors.

Provide reusable templates

Use code snippets for prompts, formulas, JSON payloads, API calls, or regex patterns. Learners can copy and adapt these templates for their own work.

How to add a code snippet to your course

  1. Open your course in Create (Edit mode).

  2. Click Add card.

  3. Select Page card type.

  4. Type / to display the list of available options.

  5. Select Code snippet from the list.

Did this answer your question?