我可以使用以下代码{{< youtube hvWSg6NblSU >}}将YouTube视频嵌入hugo网站,其中hvWSg6NblSU是以下url:https://www.youtube.com/watch?v=hvWSg6NblSU中的值
我不想嵌入单个视频,而是嵌入以下播放列表:HhjV1foHQbtGpdo0FSmsMrVykuKJ
问题:有什么方法可以嵌入上面的播放列表吗?基本上,我试着用hugo制作一个页面,它将在YouTube上显示播放列表。
在下面的链接:https://naresh-chaurasia.github.io/talk2naresh/course/python-kids/,我有一个单一的YouTube视频,但希望添加链接到整个播放列表使用雨果。有可能。
虽然我可以创建一个指向播放列表的超链接,但我想显示YouTube播放列表。
谢谢。
发布于 2022-04-30 11:31:30
它不支持内置的youtube短程序。
你能做的就是为播放列表创建一个新的youtube短代码。
步骤
/layouts/shortcodes/youtubepl.html{{- $pc := .Page.Site.Config.Privacy.YouTube -}}
{{- if not $pc.Disable -}}
{{- $ytHost := cond $pc.PrivacyEnhanced "www.youtube-nocookie.com" "www.youtube.com" -}}
{{- $id := .Get "id" | default (.Get 0) -}}
{{- $class := .Get "class" | default (.Get 1) -}}
{{- $title := .Get "title" | default "YouTube Video" }}
<div {{ with $class }}class="{{ . }}"{{ else }}style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;"{{ end }}>
<iframe src="https://{{ $ytHost }}/embed/videoseries?list={{ $id }}{{ with .Get "autoplay" }}{{ if eq . "true" }}&autoplay=1{{ end }}{{ end }}" {{ if not $class }}style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" {{ end }}allowfullscreen title="{{ $title }}"></iframe>
</div>
{{ end -}}(旁白:如果您希望有不同的短代码名,只需更改文件名即可。例如,如果您喜欢使用{{< ytplaylist >}},那么将短代码文件名更改为ytplaylist.html。)
用法
{{< youtube >}}短代码相同,只需使用新的短代码名,如:{{< youtubepl id="ID-HERE" >}}或{{< youtubepl ID-HERE >}}。https://stackoverflow.com/questions/72065012
复制相似问题