mirror of https://github.com/gohugoio/hugo
2.6 KiB
Executable File
2.6 KiB
Executable File
title | description | categories | keywords | menu | weight | toc | |||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
YouTube | Embed a YouTube video in your content using the youtube shortcode. |
|
|
true |
{{% note %}}
To override Hugo's embedded youtube
shortcode, copy the [source code] to a file with the same name in the layouts/shortcodes
directory.
[source code]: {{% eturl youtube %}} {{% /note %}}
Example
To display a YouTube video with this URL:
https://www.youtube.com/watch?v=0RKpf3rK57I
Include this in your Markdown:
{{</* youtube 0RKpf3rK57I */>}}
Hugo renders this to:
{{< youtube 0RKpf3rK57I >}}
Parameters
- id
- (
string
) The videoid
. Optional if theid
is provided as a positional argument as shown in the example above. - allowFullScreen
- {{< new-in 0.125.0 >}}
- (
bool
) Whether theiframe
element can activate full screen mode. Default istrue
. - autoplay
- {{< new-in 0.125.0 >}}
- (
bool
) Whether to automatically play the video. Forcesmute
totrue
. Default isfalse
. - class
- (
string
) Theclass
attribute of the wrappingdiv
element. When specified, removes thestyle
attributes from theiframe
element and its wrappingdiv
element. - controls
- {{< new-in 0.125.0 >}}
- (
bool
) Whether to display the video controls. Default istrue
. - end
- {{< new-in 0.125.0 >}}
- (
int
) The time, measured in seconds from the start of the video, when the player should stop playing the video. - loading
- {{< new-in 0.125.0 >}}
- (
string
) The loading attribute of theiframe
element, eithereager
orlazy
. Default iseager
. - loop
- {{< new-in 0.125.0 >}}
- (
bool
) Whether to indefinitely repeat the video. Ignores thestart
andend
arguments after the first play. Default isfalse
. - mute
- {{< new-in 0.125.0 >}}
- (
bool
) Whether to mute the video. Alwaystrue
whenautoplay
istrue
. Default isfalse
. - start
- {{< new-in 0.125.0 >}}
- (
int
) The time, measured in seconds from the start of the video, when the player should start playing the video. - title
- (
string
) Thetitle
attribute of theiframe
element. Defaults to "YouTube video".
Example using some of the above:
{{</* youtube id=0RKpf3rK57I start=30 end=60 loading=lazy */>}}
Privacy
Adjust the relevant privacy settings in your site configuration.
{{< code-toggle config=privacy.youTube />}}
- disable
- (
bool
) Whether to disable the shortcode. Default isfalse
. - privacyEnhanced
- (
bool
) Whether to block YouTube from storing information about visitors on your website unless the user plays the embedded video. Default isfalse
.