Search code examples
githubvideoyoutubeembedrestructuredtext

Embed Youtube video in GitHub readme restructuredtext (rst)


How can I do that? I found this and this, saying that raw HTML should be supported. However, I tried this, which does not work:

.. raw:: html

    <div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; max-width: 100%; height: auto;">
        <iframe src="https://www.youtube.com/embed/zIFMyBkYwqg" frameborder="0" allowfullscreen style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"></iframe>
    </div>

This is a related question for readme markdown (md) files. For markdown, raw HTML or video support seems not supported, so they embed just an image with a link to the video. If a video is not possible, then I would like to do the same, but also then, the question is how.


Solution

  • Here is in reStructuredText the code for embedding an image with a link to the YouTube video.

    .. image:: https://img.youtube.com/vi/YOUTUBE_VIDEO_ID_HERE/maxresdefault.jpg
        :alt: IMAGE ALT TEXT HERE
        :target: https://www.youtube.com/watch?v=YOUTUBE_VIDEO_ID_HERE