Barebones implementation of youtube clips on AMP pages

Add the following inside your amp templates <head> tag:

<script async custom-element="amp-youtube" src=""></script>

Step 2

Create two files in your shortcodes folder:

  1. youtube.html
  2. youtube.amp.html

Step 3

In youtube.html, add the following standard Hugo output html for Youtube clips:

<div style="position: relative; padding-bottom: 56.25%; padding-top: 30px; height: 0; overflow: hidden;">
<iframe src="//{{ .Get "src" }}?autoplay=0"
style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;" allowfullscreen frameborder="0" title="YouTube Clip"></iframe>

In youtube.amp.html, add

<amp-youtube width="480"
data-videoid="{{ .Get "src" }}">

Step 4

Insert clips using {{< youtube src=“CLIP-ID” >}}

Could probably be made even simpler, but it validates in Googles AMP test tool.