YouTube shortcode
Embed a YouTube video in your content using the youtube shortcode.
Usage
The youtube shortcode embeds the YouTube video with the given ID. The ID is the value of the v query parameter in the video’s URL. For example, the ID of the video at https://www.youtube.com/watch?v=0RKpf3rK57I is 0RKpf3rK57I.
Adjust the privacy settings for this shortcode in your project configuration. These are the default settings:
privacy:
youTube:
disable: false
privacyEnhanced: false
[privacy]
[privacy.youTube]
disable = false
privacyEnhanced = false
{
"privacy": {
"youTube": {
"disable": false,
"privacyEnhanced": false
}
}
}
disable- (
bool) Whether to disable the shortcode. Default isfalse. privacyEnhanced- (
bool) Whether to block YouTube from storing information about visitors to your site unless the visitor plays the embedded video. Default isfalse.
To override Hugo’s embedded youtube shortcode, copy the source code to a file with the same name in the layouts/_shortcodes directory.
Arguments
The youtube shortcode accepts either a single positional argument, the video ID, or named arguments. Do not mix positional and named arguments.
allowFullScreen- (
bool) Whether theiframeelement can activate full screen mode. Default istrue. autoplay- (
bool) Whether to automatically play the video. Forcesmutetotrue. Default isfalse. class- (
string) Theclassattribute of the wrappingdivelement. When specified, removes thestyleattributes from theiframeelement and its wrappingdivelement. controls- (
bool) Whether to display the video controls. Default istrue. end- (
int) The time, measured in seconds from the start of the video, when the player should stop playing the video. id- (
string) The ID of the YouTube video. Required when using named arguments. loading- (
string) Theloadingattribute of theiframeelement, eithereagerorlazy. Default iseager. loop- (
bool) Whether to indefinitely repeat the video. Ignores thestartandendarguments after the first play. Default isfalse. mute- (
bool) Whether to mute the video. Alwaystruewhenautoplayistrue. Default isfalse. start- (
int) The time, measured in seconds from the start of the video, when the player should start playing the video. title- (
string) Thetitleattribute of theiframeelement. Default isYouTube video.
Examples
content/example.md
{{< youtube 0RKpf3rK57I >}}Your browser displays this:
With named arguments:
content/example.md
{{< youtube id=0RKpf3rK57I start=30 end=60 loading=lazy >}}Your browser displays this:
Last updated:
November 16, 2026
:
content: Apply style guide to shortcodes section (bd893690d)
Improve this page