Embedding YouTube Videos in Jekyll
In my last post, iPhone 12 Pro Camera v. Professional Camera, I embedded a YouTube video by following the steps that Alex Vie provides in Ebedding YouTube videos in Jekyll:
- I added the conditional include script to a file titled
youtube.html
that I saved in the_includes
directory. - I added the required CSS to the
custom-styles.scss
file that is located in_sass
>minima
.
To add a YouTube video to a post, I can now simply include the following script, where idid
stands for the video’s ID. : {% include youtube.html id="idid" %}
. (Note that this line of code is surrounded by the tag for Liquid syntax, but I haven't figured out how to write the tag in a post without triggering the script.)
I created a TextExpander snippet that allows me to insert the code with a keyboard shortcut.
[Updated 10/15/2021]