How To Add Code Highlights On Medium Article.

aam Himel
3 min readNov 27, 2020
Photo by Chris Ried on Unsplash

When writing a medium article specially for programmers 💻 sometimes it becomes necessary to share code so that viewers can easily understand what the writer talking about. But because of the minimal article writing section, it becomes confusing😕 for the beginner how they can share their code in the medium easily. You don’t have to worry about this anymore, here I am listing the best ways to add code highlights on Medium.

Though there is a basic way to add some kind of code blocks so that your code is become separate from the rest of the text. To do that you just have to add

Put your cursor at the beginning of the line and type ``` then hit enter.

See? How easy it is to do code blocks on Medium. It becomes even more easier if you know the short cut for this:

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

Wait! I have promised you to show the actual code highlighting not the boring Black/White code! Nobody likes this anymore!

Okay, Enough to talk back to the business. You have a few options here, The famous option is by using Github Gist. It is a code-sharing system so that you share your code with anyone on the internet. And also it is fairly easy to use. To be able to create a Gist, you need to logged in to your GitHub account then go to GitHub Gitst

https://gist.github.com/

Then write the file name and file extension in the field Filename including extension… then write your code or past the code in the field. Then before creating the gist make sure to change it to Public gist, though by default it is Secrate.

Now you need to change the settings from Embed to Share like the picture :

Change settigs Embed to Share

Then Copy the link and past into the Medium and hit Enter.

Copy the URL and Past

If you do the above mensioned steps properly you will have a code section like this:

That’s it! you’ve done it!😍. Now you have a nice looking code section inside your Medium Article.

Thanks for reading. ❤️

--

--