All help topics

Add a code block

Insert a code block, set its language, give it a title, and copy it out.

Code blocks get more attention here than anywhere else in the editor, because this is a tool for people who write code. They carry a language, an optional title, line numbers and their own copy button.

  1. Put the caret on an empty line.

    If you are at the end of a paragraph, press Enter first.

  2. Type / then code, and press Enter.

    “snippet”, “pre” and “syntax” find it too.

  3. Choose a language from the picker in the block's header.

    Syntax highlighting follows the language you pick.

  4. Optionally type a title in the header, to the left of the picker.

    Useful for a filename — src/lib/auth.ts — so a long page of snippets stays readable.

  5. Click into the body and paste or type your code.

You can also start one from the keyboard alone: at the start of an empty line, type three backticks followed by a space. Add the language to the backticks — ```ts then a space — and the block arrives with that language already set.

The copy button in the block's header copies the code on its own, with no fences, ready to paste into a terminal. Copying the whole block from the block menu instead gives you a fenced Markdown version — see Copy a block.

Read next

Still stuck?

Email support@digipages.io and describe what you were trying to do and what happened instead. A link to the page you were on helps.