Embedding Rich Content: YouTube Videos

  • Post by Demo User
  • Jul 15, 2025
post-thumb

Adding videos to your articles is a great way to engage your readers and convey messages more effectively. Hugo makes it incredibly simple to embed external content like YouTube videos, thanks to built-in shortcodes.

The YouTube Shortcode

You don’t need to copy-paste the complex <iframe> code provided by YouTube. Instead, you can use the youtube shortcode. All you need is the video’s ID.

For example, here is a video about web design principles:

This is the code used to embed the video above. It’s clean and simple!

{{< youtube id="YubP_p2hY-o" title="Principles of Web Design" >}}

Why Use Shortcodes?

  1. Simplicity: They keep your Markdown content clean and readable.
  2. Security: Hugo handles the safe generation of the <iframe>.
  3. Responsive: The embedded video is typically responsive and displays well on all devices.
  4. Performance: Some themes apply optimizations like lazy loading to the video, improving page load times.

Try embedding a video in your next post and see how it enhances your content!