How to Post Code/Gists in medium?

Code can be long or short .It should be clear and understandable so here are the two methods how can you post the code in medium.

puja sharma
2 min readJun 28, 2021

METHOD 1 : Using Code Block.

If you want to post small code or write any commands you want to highlight can use Code Block.To bring the code block you can press shortcut key below:

Windows : Ctrl + Alt + 6
Mac : Cmd + Alt + 6

METHOD 2 : Using GitHub Gists

Step 1: Go to your github account

Step 2 : Click plus ( + ) sign in top right .

Step 3: Click on the New gist .

Step 4: Add description of gist on top

Step 5: Insert file name with extension (such as: .js, .java, .py etc.)

Step 6: Copy and paste the code you want to add.

Step 7 : Click on the dropdown botton and select Create public gist

Step 8: Once you create public gist click on the dropdown botton on right top select share, you can see the image below for demo:

Step 9: Copy link and paste to medium

and here you can see the demo how gist looks like:

--

--