๋ฐœํ–‰์ผ:

์ˆ˜์ •์ผ:

YouTube: How to Apply Structured Data for Faster Video Indexing

We introduce a method for automatically inserting VideoObject structured data to increase the search engine indexing speed of YouTube video content embedded in a blog and expose Rich Results. Use JSON-LD JavaScript code targeting specific iframes to optimize SEO and raise your Click-Through Rate (CTR) without manual work!.


While videos are widely used to enrich blog content, simply embedding a video player is a method that only visitors can know. When adding videos to a blog, it is very important to clearly inform search engines about the video information. Major search engines like Google and Bing understand the meaning of content through Structured Data and expose Rich Results such as thumbnails and play buttons in search results.

In particular, when video content is exposed with a thumbnail, the Click-Through Rate (CTR) significantly increases, which greatly helps in increasing visitors. At this time, VideoObject structured data is used as the standard for conveying metadata describing the video, such as the video title, thumbnail, upload date, and playback URL, which are metadata that describes the video to search engines.

Utilizing the Script for Automatic Insertion of YouTube VideoObject Structured Data

It is practically difficult to manually write VideoObject metadata in JSON-LD format for every video. Therefore, this article introduces a JavaScript code that automatically finds YouTube iframes wrapped within an area with a specific class name (custom-video-container) inside the blog, generates structured data, and dynamically inserts it into the head section.

Why structure only videos wrapped with a specific class name?
If all videos were created by yourself, there would be no problem, but if you use videos from others, copyright issues or unwanted videos may be included. Therefore, this is to selectively structure only intended videos and provide accurate information to search engines.

Applying this code:

  • Automatically recognizes specific YouTube videos embedded in your blog.
  • Adds title, thumbnail, and upload date information to the metadata for each video.
  • Enables support for SEO-optimized Rich Results without separate manual work.

1. Example of Automatic Insertion Script Code (JSON-LD Dynamic Generation)

script
document.addEventListener("DOMContentLoaded", () = {
const videoIframes = document.querySelectorAll(".custom-video-container iframe");
if (videoIframes.length === 0) return;

function extractYouTubeID(url) {
const regExp = /(?:youtube\.com\/(?:embed\/|v\/|watch\?v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/;
const match = url.match(regExp);
return match ? match[1] : null;
}

const videos = [];

videoIframes.forEach((iframe, index) = {
const src = iframe.src;
const videoId = extractYouTubeID(src);
if (!videoId) return;

// Use iframe title attribute to get video title, use default title if none
const title = iframe.title || document.title + " - Video " + (index + 1);
const thumbnail = `https://img.youtube.com/vi/${videoId}/hqdefault.jpg`;
const uploadDate = new Date().toISOString(); // Set current date as upload date (Note: this is not the actual upload date)

videos.push({
"@context": "https://schema.org",
"@type": "VideoObject",
"name": title, // Video title (automatic or using iframe title attribute)
"description": "This video is part of the blog content.", // Can be changed to a description related to the blog content
"thumbnailUrl": [thumbnail], // Thumbnail URL (automatically generated)
"uploadDate": uploadDate, // Upload date (automatically generated)
"contentUrl": src, // Video URL (iframe src)
"embedUrl": src, // Embed URL (iframe src)
"publisher": {
"@type": "Organization",
"name": "์ผ์ƒํ—ˆ๋ธŒ", // MUST change to your site or operator name
"logo": {
"@type": "ImageObject",
"url": "https://tistory1.daumcdn.net/tistory/7331789/skin/images/everyday.png" // MUST change to your site logo image URL
}
}
});
});

if (videos.length 0) {
const script = document.createElement("script");
script.type = "application/ld+json";
script.textContent = videos.length === 1
? JSON.stringify(videos[0], null, 2)
: JSON.stringify(videos, null, 2);
document.head.appendChild(script);
}
});
/script

2. How to Apply and Notes

1. Wrapping the Video (Required)

  • The video iframe tag must be wrapped with div class="custom-video-container" for the script to recognize the video.
div class="custom-video-container"
iframe src="https://www.youtube.com/embed/VIDEO_ID" title="Video Title" frameborder="0"/iframe
/div

2. Script Insertion and Information Modification

  • Insert the JavaScript code above either at the **bottom of the blog HTML head tag** or right before the closing body tag.
  • The "name": "์ผ์ƒํ—ˆ๋ธŒ" and "url": "..." (Logo URL) parts within the code MUST be modified to your operator or site information.

3. Structured Data Validation Check

  • Check the application results by entering the page URL in the Google Rich Results Test Tool.
  • The VideoObject metadata must be correctly recognized with no errors.
The sample video is a YouTube video created during meditation practice.

3. Key SEO Benefits of VideoObject Structured Data

  • Video Thumbnail Exposure in Search Results: Attracts user attention with a visual element on the search results page, drastically increasing the click-through rate.
  • Increased Click-Through Rate via Rich Results Exposure: Rich information such as video duration and upload date is exposed, allowing users to pre-evaluate content quality.
  • Increased Content Recognition in AI and Voice Search: Search engines understand video content more accurately, increasing the likelihood of exposure in AI-based search services or voice search results.
  • Enhanced Blog Content Credibility and Expertise: Providing structured data signifies compliance with web standards, contributing to increased credibility of blog content from search engines.
๊ฒ€์ƒ‰ ์—”์ง„์ด ๋™์˜์ƒ์„ ๊ฐ์ง€ํ•˜๊ณ  ์ƒ‰์ธ์— ๋“ฑ๋ก
Search engines detect videos within the page and include them in the search index

4. Summary: Maximizing SEO Effects with Automated Video Structuring

The automatic structured data insertion using JavaScript, as described, is very useful, especially for blog operators with a lot of video content. Without needing to manually write metadata one by one, simply applying the code and wrapping the video with a specific class automatically creates up-to-date JSON-LD data, maximizing the SEO effect.

We strongly recommend utilizing this method, as it provides a better user experience for both blog visitors and search engines! If you have any questions or need assistance with application, feel free to ask anytime. This concludes the introduction to the automatic VideoObject structured data insertion method. Happy blogging!

Frequently Asked Questions (FAQ)

What is the difference between simply embedding a player when inserting a video into a blog and providing video information to search engines as structured data?

Simply embedding a player only shows the video to the user. In contrast, providing structured data (VideoObject) allows search engines to clearly recognize metadata such as the video title, thumbnail, and upload date, exposing Rich Results (thumbnails, play buttons, etc.) in the search results. This increases the visual effect in search results, leading to a significant increase in Click-Through Rate (CTR) and blog visitor count.

What is the method for effectively structuring multiple YouTube videos on a blog?

Manually writing metadata for multiple videos is inefficient. Instead, using JavaScript that automatically recognizes YouTube iframes wrapped in a specific class name (e.g., custom-video-container), generates VideoObject structured data in JSON-LD format, and dynamically inserts it into the HTML <head> allows for easy automation of SEO optimization and Rich Results support.

Is it okay that the upload date (uploadDate) of the VideoObject generated by JavaScript is different from the actual video upload date?

The provided script sets the current date at the time the code is executed as the uploadDate. This may differ from the actual YouTube video upload date. While search engines can use this information to judge the video's recency, it is better to manually retrieve and apply the video's actual upload date to provide the most accurate information. However, considering the convenience of automation, this method remains a good alternative for providing valid metadata for indexing.