Here’s a super simple way to add schema to a YouTube video without having to wrap schema item properties inline with an embedded video. Adding schema markup inline has proven to be difficult, especially when adding it to a website that has already been designed and developed, sometimes with videos written in the actual page template.
It also seems that you can’t hide the video description on the front end of a site when the item property is written inline. So this can become redundant on a page where you’re already talking about the same topic as your video.
With this method, just grab the embed code for the YouTube video and paste that into your page body. Then, open up your favorite text editor and paste this as your template
<script type="application/ld+json"> { "@context": "http://schema.org/", "@type": "VideoObject", "name": "Light at the End of the Tunnel", "description": "Description", "thumbnailURL": "http://i.ytimg.com/vi/IbvuM5M87zE/hqdefault.jpg", "UploadDate": "2013-11-28" } </script>
Replace the name with the name of your video, as well as the description (make sure you copy and paste it so it’s consistent) and the upload date. This can all be found in the video description panel in YouTube.
Edit the thumbnail URL to remove the video ID and copy over your own. The YouTube video ID is just the last string of characters in the URL when you watch a video.
You can add additional markup as needed, like the author of the video. See schema.org for other item properties you can add to a video object.
Make sure you’re using the right quotation marks in the markup. It’s the tiniest mistake that can throw off Google’s bots. Take note:
Make sure your items are wrapped in "these" kind of quotes and not “these“.
After you’ve created the code (and tested it through Google’s Structured Data Testing Tool, add it to the <head> of the page the video is on. I’ve found the Per Page Add To plugin to be really easy to use. It creates a field in the page editor where you can paste your markup into.
Neet trick 🙂
Thanks