Testing a new shortcode

Let’s see if we can get this shortcode working, which will allow us to embed a YouTube video with a start and end time.

Here is Chris Bail, introducing topic models, dropping some knowledge about setting explicit seeds for reproducible results. I want friends who do topic models.


The shortcode file youtubestartend.html contains:

<!-- https://discourse.gohugo.io/t/howto-youtube-embed-with-custom-start-time/7060/6 -->
<div style="position: relative; padding-bottom: 56.25%; padding-top: 30px; height: 0; overflow: hidden;">
    <iframe src="http://www.youtube-nocookie.com/embed/{{ index .Params 0 }}?start={{ index .Params 1 }}&end={{ index .Params 2}}"
    style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;" allowfullscreen frameborder="0" title="YouTube Video"></iframe>
</div>

and is placed in the directory layouts/shortcodes/blogdown/.

The embedded code, used above, is:

{{< blogdown/youtubestartend IUAHUEy1V0Q 518 539 >}}

…and incidentally, the way you present the above code, without having the shortcode actually rendered by Hugo, is explained in this Infinite Ink post. Basically, you put the entire shortcode between /* C comment delimiters */:

{{</* blogdown/youtubestartend IUAHUEy1V0Q 518 539 */>}}

…and to render THAT text above, you have to do double delimiters:

{{</*/* blogdown/youtubestartend IUAHUEy1V0Q 518 539 */*/>}}

…and so forth.

Edit this page

Steve Linberg
Steve Linberg
Masters student in Data Analytics and Computational Social Science at the University of Massachusetts Amherst

Programmer since before you were born. Sysadmin/DBA for a couple decades. Painter in a parallel universe. Now a student again.

Related