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.
Put the caret on an empty line.
If you are at the end of a paragraph, press Enter first.
Type / then code, and press Enter.
“snippet”, “pre” and “syntax” find it too.
Choose a language from the picker in the block's header.
Syntax highlighting follows the language you pick.
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.
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
The / menu: every block you can insert
Type / on an empty line to insert any kind of block, and filter the list as you type.
Change, move or delete a block
Turn a paragraph into a heading, insert around it, or remove it — from the block menu.
Copy a block
Copy a block as Markdown for elsewhere, or as itself for another DigiPages page.
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.