YouTube is a great way to host video your Jekyll site. It’s free, loads quickly, is reliable and it’s easy to embed in your site.


  1. Find your video on YouTube then go to Share -> Embed
  2. Copy the embed code to a new include _includes/youtube.html.
  3. Replace the end part of the iframe src url with a variable youtube_id:
    <iframe width="560" height="315" src="" frameborder="0" allowfullscreen></iframe>

Now you can use this include anywhere in your site by passing it the id of the YouTube video

<div class="video_wrapper">
	<iframe src="" frameborder="0" allowfullscreen></iframe>

Responsive YouTube video

The include above works fine but the videos are always the same size. If you have a responsive site it’s better if the video scales so it always makes use of the available space.

With a few tweaks to the include script you can achieve this. We’ll add a div around the iframe and remove the width and height. I’ve also added ?rel=0&modestbranding=1&showinfo=0 to the src URL which removes some of the YouTube branding and makes it display cleaner:

<div class="video_wrapper">
  <iframe src="" frameborder="0" allowfullscreen></iframe>

To finish off we’ll add some CSS. This forces the video to always be the full width of is container and to maintain a particular aspect ratio. In this case we have a ratio of 16:9 which gives us padding-bottom: 56.25%; (9/16):

.video_wrapper {
	position: relative;
	padding-bottom: 56.25%;
	padding-top: 25px;
	height: 0;

.video_wrapper iframe {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;