You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何为网站Meta标签添加YouTube视频及将Facebook视频配置至og:video Meta标签(含Google合规要求解决方案)

Hey there! Let's tackle your questions one by one to get everything sorted out for you:

Adding YouTube Videos to Your Site's Meta Tags

If you want social platforms (like Facebook or Twitter) to show a YouTube video preview when your site is shared, or help search engines recognize the video content, you’ll want to use Open Graph (OG) meta tags. Here’s the standard setup:

  • Grab your YouTube video ID (it’s the string after watch?v= in the video URL, e.g., abc123 from https://www.youtube.com/watch?v=abc123).
  • Add these OG tags to your <head> section:
    <meta property="og:video" content="https://www.youtube.com/embed/abc123">
    <meta property="og:video:type" content="text/html">
    <meta property="og:video:width" content="1280">
    <meta property="og:video:height" content="720">
    
    The embed URL (youtube.com/embed/[ID]) is preferred here because it’s optimized for platform crawlers to fetch and display the video preview.
Adding Facebook Videos to the og:video Meta Tag

For Facebook-hosted videos, the process is similar but uses Facebook’s embed URL instead:

  1. Go to your Facebook video page, click the "Embed" button, and copy the src value from the generated iframe code (it’ll look like https://www.facebook.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2F[PAGE_NAME]%2Fvideos%2F[VIDEO_ID]%2F).
  2. Add these OG tags to your <head>:
<meta property="og:video" content="https://www.facebook.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2F[PAGE_NAME]%2Fvideos%2F[VIDEO_ID]%2F">
<meta property="og:video:type" content="text/html">
<meta property="og:video:width" content="560">
<meta property="og:video:height" content="315">

Make sure your Facebook video is set to public—otherwise, crawlers won’t be able to access it to generate previews.

Understanding Google’s Head Tag Guidelines

You’re spot-on about that Google rule: never put <iframe> or <img> tags inside your <head> section. Here’s the official context you referenced:

HTML规范规定,head标签中仅允许包含上述提及的元素,其余元素均为无效元素。常见的会导致head标签失效的元素包括:iframe、img。我们强烈建议不要在head标签中使用这些无效元素;若必须使用,请将这些无效元素放置在希望Google抓取的元素之后。一旦Google检测到此类无效元素,会判定head标签结束,停止读取后续的head元素。

If you need to embed a video on your page, always put the <iframe> in the <body> section (where your page content lives). Putting it in the <head> doesn’t help search engines recognize the video anyway—they use meta tags and structured data for that, not misplaced iframes.

Getting Video Previews in Google Search Results

To make your site show a video preview next to its search listing, you need to meet a few key requirements:

  • Add Schema.org structured data: Use the VideoObject type to tell Google all the important details about your video. Here’s a sample:
    <script type="application/ld+json">
    {
      "@context": "https://schema.org",
      "@type": "VideoObject",
      "name": "Your Video’s Clear, Descriptive Title",
      "description": "A detailed summary of what your video covers",
      "thumbnailUrl": "https://your-site.com/video-thumbnail.jpg",
      "uploadDate": "2024-05-20T12:00:00Z",
      "duration": "PT15M30S",
      "embedUrl": "https://your-site.com/embed-your-video.html"
    }
    </script>
    
    If you’re using a YouTube/Facebook embed, use that embed URL for embedUrl.
  • Ensure crawlability: Your video page must be public (no login walls), and your robots.txt file shouldn’t block search crawlers from accessing it.
  • Use high-quality thumbnails: Aim for at least 1200x675 pixels with a 16:9 aspect ratio—this helps Google display a crisp preview.
  • Match content to video: Your page’s text content should directly relate to the video’s topic. Google won’t show a video preview if the page and video don’t align.
  • Follow content policies: Make sure your video doesn’t violate copyright or Google’s content guidelines.

You can use Google’s Rich Results Test tool to check if your structured data is set up correctly—this will flag any errors that might prevent the video preview from showing up.

内容的提问来源于stack exchange,提问作者Al Martins

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.27 13:37:33