如何将YouTube播放列表嵌入雨果网站

发布于 2025-01-25 06:10:03 字数 690 浏览 3 评论 0原文

我可以使用以下代码,{{< youtube hvWSg6NblSU >}} to embed the YouTube video in hugo website, where hvWSg6NblSU is the value in following url: https://www.youtube.com/watch?v=hvwsg6nblsu

我不想嵌入以下播放列表:

​我可以嵌入上面的播放列表。基本上,我正在尝试使用Hugo制作页面,该页面将在YouTube上显示播放列表。

在以下链接中: https://naresh-chaurasia.github.io/ talk2naresh/course/python-kids/,我有一个YouTube视频,但想使用Hugo添加到整个播放列表的链接。是否可以。

尽管我可以为播放列表创建超链接,但我想显示YouTube播放列表。

谢谢。

I can make use of the following code, {{< youtube hvWSg6NblSU >}} to embed the YouTube video in hugo website, where hvWSg6NblSU is the value in following url: https://www.youtube.com/watch?v=hvWSg6NblSU

Instead of embedding a single video, I want to embed the following playlist: https://www.youtube.com/playlist?list=PLDe3_HhjV1foHQbtGpdo0FSmsMrVykuKJ

Question: Is there a way I can embed the above playlist. Basically I am trying to make a page using hugo which will show the playlist on YouTube.

In the following link: https://naresh-chaurasia.github.io/talk2naresh/course/python-kids/, I have a single YouTube video but want to add link to entire playlist using hugo. Is it possible.

Although I can create a hyperlink to the playlist, but I want to display the YouTube playlist.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

执笔绘流年 2025-02-01 06:10:03

它不受内置的YouTube快速代码的支持。

您可以做的是为播放列表创建一个新的YouTube快速代码。

步骤

  1. 创建:/layouts/shortcodes/youtubepl.html
  2. 在该文件中放置以下位置:(基于内置的youtube短码
{{- $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 -}}

(一边:如果您希望具有不同的短代码名称,请更改文件名,例如更改文件名。 ;

,如果您喜欢

  • 使用{{& lt 代码> {{&lt; YouTube&gt;}}快捷代码,只需使用新的快捷代码名称:{{&lt; youtubepl id =“ id here”&gt;}}}{{&lt; youtubepl id-here&gt;}}
  • 您将使用播放列表ID,而不是视频ID。

It is not supported by the built-in youtube shortcode.

What you can do is create a new youtube shortcode for playlists.

Steps

  1. Create: /layouts/shortcodes/youtubepl.html
  2. In that file place the following: (based on the built-in youtube shortcode)
{{- $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 -}}

(aside: If you prefer to have a different shortcode name, simply change the filename. For example, if you prefer to use {{< ytplaylist >}} change the shortcode filename to ytplaylist.html.)

Usage

  • Usage is the same as the built-in {{< youtube >}} shortcode, just use the new shortcode name like so: {{< youtubepl id="ID-HERE" >}} or {{< youtubepl ID-HERE >}}.
  • Instead of the video ID, you'll use the playlist ID.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文