Jekyll blog hosted in github: how to insert youtube embeddings?
Asked Answered
L

3

6

I would like to be able to insert youtube videos in my Jekyll site hosted in Github.

  • There is a Jekyll plugin for embedding youtube videos but it does not work in github pages.

  • An iframe does not work either.

    <iframe width="420" src="hhtp://..." frameborder="0" allowfullscreen> </iframe>
    

Is there a way to do it or we just have to live with that?

Lordling answered 10/1, 2016 at 17:23 Comment(0)
P
16

Try :

<iframe width="560" height="315" src="https://www.youtube.com/embed/dQw4w9WgXcQ" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
Pentamerous answered 10/1, 2016 at 18:7 Comment(4)
It works! Is it because of the www.youtube.com/embedurl?Lordling
Yes. That's the embed code you can find on any youtube video page.Pentamerous
Doesn't work: Refused to display https://www.youtube.com/embed/dQw4w9WgXcQ in a frame because it set 'X-Frame-Options' to 'sameorigin'. As far as I know GitHub doesn't allow foreign-origin iframes and it seems that even locally-ran Jekyll doesn't allow these. Is there any workaround?Aras
Actually, it works. Just ensure that /embed/ exists in the uri.Ovi
S
3

One minor addition to the response of @David Jacquel: the secure https is crucial for it to work in Github Pages (whereas the not secure http might be enough for it to work locally).

Shank answered 1/1, 2021 at 13:33 Comment(0)
P
2

It is possible to get the HTML directly from youtube.

Simply

  1. Go to the youtube video you'd like to embed.
  2. Click SHARE.
  3. Click Embed.
Pamphylia answered 15/10, 2021 at 10:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.