Coders — How to add source code to your Medium articles

Sherlynn
2 min readJan 1, 2019

So as I was writing an article pertaining to coding work, I knew that I could add Code blocks & Inline code as a feature provided by Medium.

Code block

To begin a code block, on a new line type in ``` (triple backtick).
Keyboard shortcut: ⌘ + Opt + 6 / Ctrl + Alt + 6.

This is 
an example of a
code block

Inline code

For inline code in a paragraph, type a single backtick ` to begin and end your code. Or highlight some text and press the backtick key.

An example of an inline code

Note: Code blocks and inline code are not supported on mobile.

Adding Source code

At times, I would prefer to display the source code especially when the code is lengthy. This provides for better readability and added color.

We can use Github Gists, Codepen.io, or JSfiddle. Paste your snippet URL from one of those sources to a new line in the editor and press Enter. The Source code will be embedded automatically.

A walkthrough for using Github Gists:

Example code:

<html>
<head>
<title>How to add source code to…

--

--