Skip to main content

Command Palette

Search for a command to run...

How to Embed Preview Links in Markdown on a Hashnode Blog

Here is how you can embed preview cards for web resources like Github Repos, YouTube Videos, Tweets, CodePen snippets and other articles

Published
2 min read
How to Embed Preview Links in Markdown on a Hashnode Blog
F

I'm a software engineer and computer scientist now a Deep Tech "super angel" and founding partner of the VC fund Silicon Roundabout Ventures

Yes, you can show live previews of internet links right on your Hashnode blog.

An embedded link has its content appear as part of a post and supplies a visual element that encourages increased click-through and engagement.

First thing first: in general, Markdown supports HTML tags. Which means that it also supports <iframe>.

So if you need to, say, embed a YouTube video, you can just copy and paste the embed code from them, drop it into a Markdown document, and you should be good to go. You don’t need to do anything special to embed third-party media in Markdown.

Here is what aYouTube embeds look like using this method:

You do need to do whatever is necessary for that particular service though, and some services give you <script> based series of tags that not all Markdown implementations support.

In the example above, the code I got from YouTube clicking "Share", then "embed" is:

<iframe width="560" height="315" src="https://www.youtube.com/embed/oavMtUWDBTM" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

Method 2 ─ The Hashnode Way

Hashnode uses Embed.ly to support all sorts of embed on the platform. Which means that your Hashnode-powered blog also supports them by default. No need to paste on the platform any specific embed code. Just follow the following syntax and the magic will happen.

Here is what I mean:

To embed the same YouTube video above, you can simply type:

%[https://www.youtube.com/watch?v=oavMtUWDBTM]

Here is what you get:

Cool isn't it?

And you can do that also with github repositories, tweets and articles, as well as with a host of other online objects...

All you have to do is to follow this simple syntax:

%[Paste-link-to-embed]

Here are the examples Hashnode provides you with in its guide:

//Embed Tweets
%[https://twitter.com/hashnode/status/1080795453115920384?s=20]

//Embed YouTube Videos
%[https://www.youtube.com/watch?v=vAKtNV8KcWg]

//Embed Github Repo
%[https://github.com/hashnode/hashnode-cli]

//Embed Codepen
%[https://codepen.io/zephyo/pen/MZbLwV]

//Embed Glitch
%[https://glitch.com/edit/#!/lithium-battery-recycling]

//Embed Soundcloud
%[https://soundcloud.com/androidauthority/024-prime-day-shmimeday]

//Embed Expo
%[https://snack.expo.io/@iamshadmirza/tinder-cards]

//Embed Loom
%[https://www.loom.com/share/1436e60ced174f37b729be61081e069d]

//Embed Vimeo
%[https://vimeo.com/258358902], additional valid parameters can be 
passed to customize the player. 
Ex. %[https://vimeo.com/258358902?width=820&color=ED5565]
Visit this link https://developer.vimeo.com/api/oembed/videos for more
details on how to customize the player, supported URL types and parameters.

//Embed Canva
%[https://www.canva.com/design/your-design-id/view]

//Embed any article on web or website
%[https://hashnode.com]

Conclusion

So there you have it.

If you want to embed stuff on your Hashnode blog, all you have to do is.... type :)

I'm loving it so far. Want to try it out? Give it a go

M

Thanks for the article Francesco. I thought this is what I exactly need as I try to reshare an article. I tried your suggested solution:

%[https://www.syntaxtechs.com/blog/what-is-sdet]

But it does not display the preview. Do you know how I can solve that?

F

Hey man. I know that Hashnode uses the Embedly API. The documentation of the original library is here: https://docs.embed.ly/docs/embedly-api

So I assume this particular website does not support being rendered with an enhanced display.

For example YouTube uses oEmbed.

You can contact them to double check but in general I'd say that if it does not support it you can either try the iframe method or "fake it" with a picture and a link.

1
M

Thanks for the advice. Francesco Perticarari

The Techie VC Journal

Part 6 of 7

In this series, I will share opinions, reflections and 'non-how-to' stuff that might be relevant to fellow coders, entrepreneurs, and/or investors.... As well as any other personal blog article

Up next

What Are The Main Career Pathways For A Software Engineer?

Explore what "lies at the end of the work tunnel" from the eyes of a CTO who wore many hats in the programming field