Make youtube links work with Jekyll & Github Pages
I try with the youtube plugin. It works fine at my local machine, but it does not at Github Pages (official documentation).
Them I did it with some coffeescript.
- At the markdown post, I added this small HTML snippet
<div id="youtube_video_id" class="youtube"></div>. - At
_includes/footer.html, which is called at mydefaultlayout. I put this line:<script src="/assets/js/youtube.js"></script> - And add this new file:
assets/js/youtube.coffee
---
---
$ ->
$('.youtube').each ->
width = 560
height = 420
$(@).append "<iframe width=\"#{width}\" height=\"#{height}\" src=\"https://www.youtube.com/embed/#{@id}\" frameborder=\"0\" allowfullscreen></iframe>"Some advices here: the file must start with 2 lines of ---. Since the file has extension .coffee, the script at src requires the same file with extension .js.