Español↳ Start a project

Online Video Agent

How to Embed a YouTube Video on Your Website

Online Video AgentPublished

  • youtube embed
  • website video
  • wordpress
  • page speed
Plumber in navy coveralls sitting on an open van tailgate with a laptop on his knees showing a service page, a red toolbox on the ground beside the van

Open your video on YouTube, click SHARE, select Embed, copy the HTML code, and paste it into your page's HTML. The player appears right where you pasted it.

If your site runs on WordPress, Wix, Squarespace or Shopify, you may not need the code at all. Each has its own video block that takes the plain YouTube address, and the steps for all four are below.

If the player shows up blank or says the video is unavailable, the cause is often a privacy or embedding setting on the video itself. That list is below too.

Key takeaways

Key takeaways

Hover a point to highlight it. Click to pin it.

How to embed a YouTube video on your website

Do this on a computer, as of November 2026:

  1. Open the YouTube video or playlist.
  2. Click SHARE.
  3. Select Embed.
  4. Copy the HTML code.
  5. Paste the code into your website's HTML.

Before you copy, look at the options in the embed box. YouTube's embed help lists three: Start at, Show player controls and Enable privacy-enhanced mode.

Start at adds a start value to the code. You can also type it yourself by adding ?start= and a number of seconds to the address, such as ?start=90 to begin at one minute thirty.

A playlist works the same way. Open the playlist, choose SHARE, then Embed, copy the code and paste it in. A playlist can stop short if one of its videos is private, age-restricted or has embedding turned off.

That's it.

Embedding in WordPress, Wix, Squarespace and Shopify

A site builder can take the YouTube address instead of the code. The menu names below are the ones each platform's help pages use.

Woman at a shop office desk pasting a video into a page on a monitor, a red mug at her elbow beside a ring binder

WordPress.com. Add a YouTube block from the block inserter, paste the video URL and click Embed. You can also paste the URL on its own line, or put YouTube's iframe code in a Custom HTML block. The WordPress.com YouTube block handles standard videos, playlists and live streams, and has a Resize for smaller devices setting.

Wix. In the Wix Editor, choose Add Elements, then Video and Music, then Single Video Players, then YouTube Video. Drag it onto the page, click Change Video and paste the URL. For a playlist or channel, use Wix Video and add the playlist URL through the Video Library. An HTML code element also takes YouTube's embed code. The Single Video Player starts from the beginning, so a timestamp needs the HTML route.

Squarespace. Edit the page, click Add block or +, and select Video. Open the block editor, choose Add from link, paste the YouTube URL into Video URL and click Add. For custom playback options or your own embed code, use an Embed block instead. See Squarespace video blocks.

Shopify. On a product page, go to Products, open the product, then Media, then Add from URL, and choose YouTube or Vimeo URL. On other storefront pages, the method depends on your theme. If the theme offers a video section, use Online Store, Themes, Edit theme, then Add section or Add block. Otherwise a custom iframe goes in through the theme's HTML or Liquid tools.

Embedding by platform

Hover or tap a row to highlight it.

PlatformWordPress.com
Where the YouTube address goesA YouTube block, then click Embed
PlatformWix
Where the YouTube address goesAdd Elements, Video and Music, Single Video Players, YouTube Video, then Change Video
PlatformSquarespace
Where the YouTube address goesA Video block, Add from link, then Video URL
PlatformShopify
Where the YouTube address goesProducts, the product, Media, Add from URL

Make the video fit a phone screen

An iframe pasted with a fixed width and height can stretch the layout or create sideways scrolling on a phone. The fix is a fluid width inside a container that holds the shape.

Plumber's bare hand holding a phone in a red case in the cab of a work truck, the screen showing a web page with the video fitting the full width

For a standard landscape video, set the iframe width to 100% and put it in a container with a 16 / 9 aspect ratio. The container sets the height, and the iframe fills it. This is the approach MDN's aspect-ratio guide describes for third-party video.

``html <div class="youtube"> <iframe src="https://www.youtube.com/embed/VIDEO_ID" title="YouTube video" allowfullscreen> </iframe> </div> ``

```css .youtube { width: 100%; aspect-ratio: 16 / 9; }

.youtube iframe { width: 100%; height: 100%; border: 0; } ```

Replace VIDEO_ID with the ID from your video's address. For a vertical video, use its real ratio instead of forcing 16:9.

When the video will not play

If the player is blank, check these in order.

Plumber kneeling at an open under-sink cabinet in a home kitchen, a phone propped on a tool tray on the floor showing a paused video frame, a red pipe wrench handle on the tray

The video is private. A private video does not work in an ordinary public embed, and an existing embed stops working when a video is made private. An unlisted video can be embedded as long as it stays accessible and embedding is on.

Embedding is turned off. In YouTube Studio, open Content, select the video's Details, choose SHOW MORE, tick Allow embedding and click SAVE. If you do not own the video, you cannot change this; the owner has to.

The video is age-restricted. Age-restricted videos generally redirect viewers to YouTube instead of playing on a third-party site.

The video was deleted. There is nothing left to play, so the embed cannot continue.

You tested the iframe address on its own. Opening the iframe URL directly in a browser tab may show error 153, because the address lacks the referrer a real page provides. Test the player inside your actual page.

It is a Short. Some builders want a standard address, so change /shorts/VIDEO_ID to /watch?v=VIDEO_ID. Wix documents this limit.

Speed and privacy on your page

A YouTube player that loads the moment the page opens adds work for a visitor's browser, and several of them add more. If the video sits lower on the page, a facade can hold the load back. A facade is a light placeholder that looks like the player. When the visitor clicks, the full YouTube player replaces it. Google's facade guidance names lite-youtube-embed as one option. Autoplay may not work consistently on a lazily loaded video.

For privacy, tick Enable privacy-enhanced mode in the embed box. It changes the address from https://www.youtube.com/embed/VIDEO_ID to https://www.youtube-nocookie.com/embed/VIDEO_ID. Views from that embed are not used to personalize the viewer's YouTube experience or ads outside your site, and ads in that player are non-personalized.

It does not remove all data processing. If a viewer clicks out to YouTube, the destination can track under its own policies. The UK ICO says embedded video can use storage that needs consent, so a business with EU or UK visitors should not treat youtube-nocookie.com alone as settled. Check your consent setup, and use a consent gate or click-to-load facade where it is required. Your jurisdiction decides the rest, so take legal advice if you are unsure.

Frequently Asked Questions About Embedding YouTube Videos

Can I embed a YouTube Short?

Yes, but some builders only accept the standard address. Change /shorts/VIDEO_ID to /watch?v=VIDEO_ID if your builder rejects the Shorts link.

Can I embed an unlisted YouTube video?

Yes, as long as the video stays accessible and Allow embedding is on.

Can I start the embed at a certain time?

In pasted iframe code, add ?start= and the seconds, such as ?start=90. Some builders do not pass that value along; the Wix Single Video Player starts from the beginning.

Can I hide the YouTube controls or branding?

The controls parameter changes the player controls. YouTube decides the branding treatment from player size, parameters and other signals, so you cannot switch it off.

Will an embedded video slow my site?

It can, if the full player loads right away or you have several on one page. A click-to-load facade defers the player until the visitor interacts.

Check it on your phone before you publish

Paste the video in, save the page, and open it on your own phone. If the player fits the screen, plays, and starts where you meant it to, the job is done.

Your phone is the quickest test.

If you would like help making a video worth putting on your page, Online Video Agent can help, and you can talk to us about your videos.

Terms in this article

Tap a term to see what it means.

Facade. A light placeholder that looks like the player. When the visitor clicks, the full YouTube player replaces it.

Sources

Related articles

We remember your display settings and cookie choice on this device. Analytics and external videos stay off until you allow them. No advertising trackers are used.

Cookie policy ↗