How to add code in your Medium Blog

Michie Riffic
MichieRiffic
Published in
1 min readOct 30, 2016

Writing this down because I keep on forgetting. Right now, there are two ways to right code in your medium blog.

USING COMMAND-ALT-6 for MAC or CTRL-6 for Windows

  1. Highlight the necessary text that is your code snippet
  2. Type Command-ALT-6 for MAC or CTRL-6 for Windows

RESULT:

//hello, this is my code.

USING Github Gist

You can now embedded Github Gist on your Medium Blog.

  1. Have a Github Account. It’s Free.
  2. Go to https://gist.github.com.
  3. Create a New Gist. Add a description if you want, add the code snippet that you want to share then publish it whether it’s a secret gist or public gist. It will both work.
  4. Copy the URL of your gist.
  5. Paste it here on Medium then press enter. If you didn’t press enter, it will only show your gist URL and not the Github gist.

Example #1: Paste it in Medium without pressing enter — result: Gist URL

https://gist.github.com/michieriffic/0ff84bee16cbeec029a9d5aaee1fc0e5

Example #2: Paste it in Medium and pressing enter — result: Github Gist

If you enjoy this quick tip, you can give it a ❤ or share it out. Thanks! :)

--

--