Embed Code in Medium

Embedding code in Medium is pretty easy. There are two ways to primarily do it — by embedding the code directly on to medium or embedding it using Github Gist.

1. Embed directly in medium

To embed code directly in medium, type in Command+ Option+6 (if you use mac)

If you use other OS, this is what you got to type:

  • Windows: Control + Alt + 6
  • Linux: Control + Alt + 6

When you press these keys, a grey box as below will come up, inside which you can paste your code.

<paste your code here>

2. Embed using Github Gist

Github Gist is a much more appealing and readable option compared to directly embedding using Medium.

How this works is pretty simple. First, you have to create a Github gist.

To do this, log in to your Github profile and go to ‘your gists’.

You’ll be taken to a page like this. Enter your code snippet’s title, description and paste the code in the body.

You can then save it as a public or secret gist. If you are looking to publish it on medium, then you should be saving your gist as public.

Now that this is done, all you need to do is copy the link to your gist and embed it in medium using the embed link option.

This is how your gist will then look on medium.


Net net, this is pretty simple. The good thing about using Gists is also that you need only edit the Gist and the changes will be reflected here on medium.