I'd previously explored 2 options for embedding videos in Jekyll posts (I'm hosted oh gh-pages, and so am limited in the available plugins):
-
Placing an image in the page, which links to another site (such as Vimeo or YouTube) to play the video, as discussed in an earlier post.
-
Use the full embed code, as you can copy from Vimeo or YouTube, such as:
{% highlight html wrap %}
While these work, I didn't like that for #1 visitors are taken away from the site, and away from the context of the video, and #2 is a little cumbersome for my mobile phone based editing workflows.
In this post I am experimenting with a 3rd way - which involves creating a simple .html file in _includes directory, which contains the full embed code, and into which we can pass the YouTube ID, then you can embed the video in the following way:
{ % include youtubePlayer.html id="IvUU8joBb1Q" %}
{% include youtubePlayer.html id="IvUU8joBb1Q" %}
- Note: I initially read of this method from this blog post.