Video integration with Jekyll ================================================================================ Adding some functionality to Jekyll to allow integration of YouTube videos is a pretty easy task. First we need a couple of things: 1. A nice video hosted on YouTube 2. The embed code for the video 3. A Jekyll theme that supports video embedding The first two things are easy enough to produce. The third thing is a bit more complicated, but hopefully after reading this post you’ll have integrated YouTube videos in your Jekyll blog in no time. Working with the YouTube embed code The embed code YouTube gives you contains most of the bits we need, here is an example from the video above: We need to break this in to two parts to use it with Jekyll, and set up some new YAML front matter (https://blog.omgmog.net/post/adding-more-post-metadata-to-jekyll-with-yaml/) to make the inclusion of videos simple. Setting up the YAML When you create a new post in Jekyll, you will have the usual YAML block at the top of your file, such as the following: --- title: "Some awesome post" --- To begin, we need to add a new line before the last --- to define a YouTube embed url, which we take from the YouTube embed code. I’m using the src from the embed code above in the example below: --- title: "Some awesome post" iframe_url: https://www.youtube.com/embed/fyY9tb8Rvlk --- Tweaking the embed code Now, within our page template we will have access to the page.iframe_url property, so we can set up some template logic to render the YouTube video. We will be taking the embed code as above, and changing a few things: {% if page.iframe_url %}