Add video to GitHub README
YouTube videos can’t be embedded in GitHub READMEs.
TL;DR
Contents
- Basic markdown implementation (no styles)
- Make image contents a link
- Provide a meaningful alt text
- Rely on default styling
- Take styling into your own hands
- If you don’t have a thumbnail, get the one from YouTube
- More than you care to know on YouTube thumbnail url schemas
- Improve visual hints
Basic markdown implementation (no styles)
Start by uploading a thumbnail image.
Note
You should have an image like this:
Make image contents a link
Wrap the image markdown in a link to YouTube video.
Provide a meaningful alt text
I prefer to use the video title with the prefix: YouTube tutorial:
.
Rely on default styling
If you upload a large enough image, GitHub’s default styling will make the image responsive to the container.
Take styling into your own hands
To take styling into your own hands, you’ll need to do all this with HTML instead of markdown.
You can use the markup that GitHub uses.
I’ve added a width
rule to make sure the image is always scaled to full-width.
*Note: Most attributes get sanitized away. So there’s not a whole lot else you can do.
If you don’t have a thumbnail, get the one from YouTube
This site will get the YouTube hosted thumbnails for your video.
Note: This URL differs slightly from those used on YouTube. The subdomain is i3
instead of i
.
More than you care to know on YouTube thumbnail url schemas
YouTube offers a number of thumbnail quality alternatives.
Great stack overflow on the topic of YouTube thumbnail URLs.
Note: maxresdefault
variants aren’t guaranteed to be available. But they should be if you’re uploading your own thumbnail — which you should be.
Improve visual hints
For this use case, I’m exporting a variant of my thumbnail with a “play button” overlay.