Skip to Content
MediaYouTube Embeds

YouTube Embeds

Embed a YouTube video directly into your page so visitors can watch it without leaving your site.

Syntax

<youtube-embed id="VIDEO_ID">

Replace VIDEO_ID with the unique identifier from the YouTube video’s URL (explained below).


How to Find the Video ID

  1. Go to the YouTube video you want to embed.
  2. Look at the URL in your browser’s address bar. It looks like this: https://www.youtube.com/watch?v=dQw4w9WgXcQ
  3. The video ID is the part after v=. In this example, it is: dQw4w9WgXcQ
  4. Copy just that ID (the letters and numbers after v=, up to any & symbol).

Examples

Basic video embed

Type this in Contentful:

<youtube-embed id="dQw4w9WgXcQ">

What you’ll see: A full-width video player embedded in the page. The video displays with a 16:9 aspect ratio (standard widescreen) and includes all standard YouTube controls — play, pause, fullscreen, etc.


Embedding a video in the middle of content

Type this in Contentful:

## Watch Our Introduction Video Learn more about our program in this short overview. <youtube-embed id="dQw4w9WgXcQ"> For more information, contact us at info@example.com.

What you’ll see: A heading and intro paragraph, then the video player, then the text below it — all flowing naturally down the page.


Tips

  • The video must be publicly available on YouTube (not set to “Private” or “Unlisted with restrictions”).
  • The embed player fills the full width of the content area automatically — you don’t need to set a size.

Common Mistakes

Pasting the full YouTube URL instead of just the ID

Wrong: <youtube-embed id="https://www.youtube.com/watch?v=dQw4w9WgXcQ"> Right: <youtube-embed id="dQw4w9WgXcQ">

Only paste the ID — the short alphanumeric code after v= — not the entire URL.


Copying the wrong part of the URL

If the YouTube URL has extra parameters like &t=30s (a timestamp), don’t include those. Only copy the characters directly after v= up to the first &.

Example URL: https://www.youtube.com/watch?v=dQw4w9WgXcQ&t=30s Correct ID: dQw4w9WgXcQ (stop before the &)


Forgetting the closing >

Wrong: <youtube-embed id="dQw4w9WgXcQ" Right: <youtube-embed id="dQw4w9WgXcQ">

The tag must end with >.

Last updated on