How to Use Gists to Show Code Snippets
You don’t need to make a new Gist for each code snippet. Instead, display a single file from a multi-file Gist
A GitHub Gist is arguably the best way to display code snippets in a Medium post. Syntax highlight alone makes it the ideal choice. A Gist will typically consist of multiple files, which inevitably leads to the question: how do I display an individual file? Unless you're a web developer, the answer is not obvious. This post will answer that question.
You can select a file from a Gist with multiple files by appending the URL with: ?file=fileName
Basics: how to insert a Gist
To insert a Gist into your post, simply copy the URL into the Medium editor and hit enter. Voila, you have some nicely formatted code displayed.
The code above was displayed using the following URL: