Implementing structured data with JavaScript

Chrome for Developers · Intermediate ·📰 AI News & Updates ·5y ago

Key Takeaways

The video demonstrates how to implement structured data with JavaScript to make a website stand out in Google Search, covering approaches using vanilla JavaScript, popular frameworks like React, and Google Tag Manager.

Full Transcript

[Music] [Applause] [Music] hi everyone I'm excited to show you in the next 15 minutes how you can use structured data to make your website stand out more in Google search and how that can be done with JavaScript when the static implementation is infeasible we will start by looking at what structured data is and why it is a good idea for your website then we will look at ways to implement it using javascript and last but not least we'll take a look at how to test and debug your implementation all right now what a structured data and why is it useful structured data is a standardized set of additional markup that you can put on your pages to tell machines like Googlebot more about the content on your page on the right side here you can see the information for a specific product being highlighted in both the image search as well as the search results including additional information like ratings and price we call such results rich results to implement structured data you can use json-ld microdata or rdf a but we recommend using json-ld here is an example of what a json-ld block on your page might look like besides products there are many verticals that can benefit from structured data and become Milledgeville for which results here are some examples but you should check the link for the full gallery of supported verticals note that implementing structured data makes the page eligible for rich results but does not mean that we will always show them for every page that implements it so now we talked about what structured data is and how it benefits your website let's walk through a few possible implementations we've seen that the easiest way is to include a script tag the json-ld data in the page this can of course be done in the backend or straightening the HTML of a page but what are the options if you are using client-side oner JavaScript first of all it is fine to implement it dynamically with client-side JavaScript we recommend to use server-side rendering to make your website as robust as possible but there is no issue with implementing it with JavaScript per se in this session we will look at three possible implementation approaches of course you can use JavaScript without libraries or frameworks to inject structured data into your pages here is an example of a vanilla JavaScript implementation for a client-side rendering single page application it fetches the json-ld data from an api and injects it into the head of the page as Googlebot renders this page it will execute the JavaScript and the structured data will be rendered just make sure that the API is available to Googlebot and not blocked by robots.txt when you are using frameworks such as react angular or view J's you very likely have helpers or built-in functionality available to insert structured data into your pages here is an example of a react component using the schema helper utility to create typed json-ld for a person's profile page should you not have access to the code of your pages that have Google tag manager on these pages you may use a custom tag in custom variables to create structured data from the information that is on the page to do that create a custom HTML tag in your container and insert the relevant json-ld as well as the variables for the values of each field in the json-ld block then create the necessary custom JavaScript variables to extract information from the page so it can be inserted into the custom HTML tag automatically we advise not to copy and paste information from the page directly into Google tag manager as that will likely cause a mismatch between page content and structured data generated by Google tag manager to rise in the future right so we've seen three ways of generating structured data with JavaScript let's find out if our implementation works as expected there are two main tools for testing the implementations the first one is the rich results test you can paste a URL into the tool and see what structured data is recognized as well as if there are any issues with the structured data on the page when using javascript to generate structured data we recommend testing a URL instead of pasting code directly into the tool the other great tool for testing this is the Google search console in the URL inspection tool you can see the structured data that is detected and if it is valid but you can also see which pages of your site were eligible for which results and which ones have arrows or warnings to look into if you want to learn more about Google search in structured data check out our documentation at developers.google.com slash search or use this short link to read more on how to use javascript to generate structured data for your pages thanks a lot for joining and have a great day bye [Music] [Applause] [Music] you

Original Description

If you are building a great website with JavaScript, you want it to stand out in Google Search, too. To be eligible for rich results, you need to add structured data to your pages. In this session, we walk through typical approaches to do this both in popular frameworks as well as vanilla JavaScript. Resources: Generate structured data with JavaScript → https://goo.gle/2ZcpGhA Related Playlist: Day 1 → https://goo.gle/WDL20Day1 Subscribe to the Chrome Developers → https://goo.gle/ChromeDevs Speaker: Martin Splitt #webdevLIVE #javascript #structureddata event: web.dev LIVE 2020; re_ty: Publish; fullname: Martin Splitt; product: Chrome - General;
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Chrome for Developers · Chrome for Developers · 0 of 60

← Previous Next →
1 Polymer Performance Patterns (The Polymer Summit 2015)
Polymer Performance Patterns (The Polymer Summit 2015)
Chrome for Developers
2 Polymer Power Tools (The Polymer Summit 2015)
Polymer Power Tools (The Polymer Summit 2015)
Chrome for Developers
3 Chrome Dev Summit 2014 – Chrome Case Studies
Chrome Dev Summit 2014 – Chrome Case Studies
Chrome for Developers
4 Web Directions Code 2015 round up
Web Directions Code 2015 round up
Chrome for Developers
5 Maintainable Code - HTTP203
Maintainable Code - HTTP203
Chrome for Developers
6 iron-ajax… wat?! -- Polycasts #26
iron-ajax… wat?! -- Polycasts #26
Chrome for Developers
7 The Guardian - Supercharged
The Guardian - Supercharged
Chrome for Developers
8 ES2015 (next version of JavaScript), Totally Tooling Tips (S2 Ep1)
ES2015 (next version of JavaScript), Totally Tooling Tips (S2 Ep1)
Chrome for Developers
9 #AskPolymer: Rob answers all the questions ever -- Polycasts #27
#AskPolymer: Rob answers all the questions ever -- Polycasts #27
Chrome for Developers
10 The Future of JavaScript - HTTP203
The Future of JavaScript - HTTP203
Chrome for Developers
11 Data Binding 101 -- Polycasts #28
Data Binding 101 -- Polycasts #28
Chrome for Developers
12 The Guardian part 2 - Supercharged
The Guardian part 2 - Supercharged
Chrome for Developers
13 The Future of Web Audio: with Chris Wilson and Chris Lowis
The Future of Web Audio: with Chris Wilson and Chris Lowis
Chrome for Developers
14 Chrome 46: New motion-path animations, client hints and service worker improvements
Chrome 46: New motion-path animations, client hints and service worker improvements
Chrome for Developers
15 Sublime Snippets, Totally Tooling Tips (S2 Ep2)
Sublime Snippets, Totally Tooling Tips (S2 Ep2)
Chrome for Developers
16 #AskPolymer: How do you make the show? -- Polycasts #29
#AskPolymer: How do you make the show? -- Polycasts #29
Chrome for Developers
17 Critical Path CSS, Totally Tooling Tips (S2 Mini Tip #1)
Critical Path CSS, Totally Tooling Tips (S2 Mini Tip #1)
Chrome for Developers
18 Binding to Objects -- Polycasts #30
Binding to Objects -- Polycasts #30
Chrome for Developers
19 Player FM - Supercharged
Player FM - Supercharged
Chrome for Developers
20 Where’s the Designer? #AskPolymer -- Polycasts #31
Where’s the Designer? #AskPolymer -- Polycasts #31
Chrome for Developers
21 Jake Beats Wikipedia - HTTP203
Jake Beats Wikipedia - HTTP203
Chrome for Developers
22 Supercharged Observers! -- Polycasts #32
Supercharged Observers! -- Polycasts #32
Chrome for Developers
23 Jai's Web blog - Supercharged
Jai's Web blog - Supercharged
Chrome for Developers
24 Windows Command-line Tooling, Totally Tooling Tips (S2, Ep4)
Windows Command-line Tooling, Totally Tooling Tips (S2, Ep4)
Chrome for Developers
25 What about internationalization? #AskPolymer -- Polycasts #33
What about internationalization? #AskPolymer -- Polycasts #33
Chrome for Developers
26 Developing for Billions (Chrome Dev Summit 2015)
Developing for Billions (Chrome Dev Summit 2015)
Chrome for Developers
27 Google+ Performance Improvement Comparison
Google+ Performance Improvement Comparison
Chrome for Developers
28 Deploying HTTPS: The Green Lock and Beyond (Chrome Dev Summit 2015)
Deploying HTTPS: The Green Lock and Beyond (Chrome Dev Summit 2015)
Chrome for Developers
29 Progressive Web Apps (Chrome Dev Summit 2015)
Progressive Web Apps (Chrome Dev Summit 2015)
Chrome for Developers
30 Instant Loading with Service Workers (Chrome Dev Summit 2015)
Instant Loading with Service Workers (Chrome Dev Summit 2015)
Chrome for Developers
31 Increase Engagement with Web Push Notifications (Chrome Dev Summit 2015)
Increase Engagement with Web Push Notifications (Chrome Dev Summit 2015)
Chrome for Developers
32 Engaging with the Real World: Web Bluetooth and Physical Web (Chrome Dev Summit 2015)
Engaging with the Real World: Web Bluetooth and Physical Web (Chrome Dev Summit 2015)
Chrome for Developers
33 Asking for Permission: respectful, opinionated UI (Chrome Dev Summit 2015)
Asking for Permission: respectful, opinionated UI (Chrome Dev Summit 2015)
Chrome for Developers
34 Polymer - State of the Union (Chrome Dev Summit 2015)
Polymer - State of the Union (Chrome Dev Summit 2015)
Chrome for Developers
35 Building Progressive Web Apps with Polymer (Chrome Dev Summit 2015)
Building Progressive Web Apps with Polymer (Chrome Dev Summit 2015)
Chrome for Developers
36 Introduction to RAIL (Chrome Dev Summit 2015)
Introduction to RAIL (Chrome Dev Summit 2015)
Chrome for Developers
37 DevTools in 2015: Authoring to the max (Chrome Dev Summit 2015)
DevTools in 2015: Authoring to the max (Chrome Dev Summit 2015)
Chrome for Developers
38 RAIL in the real world (Chrome Dev Summit 2015)
RAIL in the real world (Chrome Dev Summit 2015)
Chrome for Developers
39 #ChromeDevSummit talks are up - W00T! -- Polycast #34
#ChromeDevSummit talks are up - W00T! -- Polycast #34
Chrome for Developers
40 V8 Performance from the Driver's Seat (Chrome Dev Summit 2015)
V8 Performance from the Driver's Seat (Chrome Dev Summit 2015)
Chrome for Developers
41 Quantify and improve real-world RAIL (Chrome Dev Summit 2015)
Quantify and improve real-world RAIL (Chrome Dev Summit 2015)
Chrome for Developers
42 Owning your performance: RAIL (Chrome Dev Summit 2015)
Owning your performance: RAIL (Chrome Dev Summit 2015)
Chrome for Developers
43 HTTP/2 101 (Chrome Dev Summit 2015)
HTTP/2 101 (Chrome Dev Summit 2015)
Chrome for Developers
44 Leadership Panel (Chrome Dev Summit 2015)
Leadership Panel (Chrome Dev Summit 2015)
Chrome for Developers
45 Build Processes, Totally Tooling Tips (S2, Ep 5)
Build Processes, Totally Tooling Tips (S2, Ep 5)
Chrome for Developers
46 Accessibility (Chrome Dev Summit 2015)
Accessibility (Chrome Dev Summit 2015)
Chrome for Developers
47 Binding to Arrays -- Polycasts #35
Binding to Arrays -- Polycasts #35
Chrome for Developers
48 HTTP2 - HTTP203
HTTP2 - HTTP203
Chrome for Developers
49 Chrome 47: Splash Screens, requestIdleCallback and better desktop notifications (New in Chrome)
Chrome 47: Splash Screens, requestIdleCallback and better desktop notifications (New in Chrome)
Chrome for Developers
50 Call For Submissions - Supercharged
Call For Submissions - Supercharged
Chrome for Developers
51 Cross Device Testing, Totally Tooling Tips (S2 Ep6)
Cross Device Testing, Totally Tooling Tips (S2 Ep6)
Chrome for Developers
52 Testing AJAX with Web Component Tester -- Polycasts #37
Testing AJAX with Web Component Tester -- Polycasts #37
Chrome for Developers
53 Slack: Extended Xmas Special - Supercharged
Slack: Extended Xmas Special - Supercharged
Chrome for Developers
54 Browser testing with Travis & Sauce Labs -- Polycasts #38
Browser testing with Travis & Sauce Labs -- Polycasts #38
Chrome for Developers
55 Optimize for production with Vulcanize -- Polycasts #39
Optimize for production with Vulcanize -- Polycasts #39
Chrome for Developers
56 Highlights from Chrome Dev Summit 2015
Highlights from Chrome Dev Summit 2015
Chrome for Developers
57 Chrome 48: Custom buttons in notifications, DevTools Security panel, and Presentation mode
Chrome 48: Custom buttons in notifications, DevTools Security panel, and Presentation mode
Chrome for Developers
58 Crisper: Protecting your Polymer app with CSP -- Polycasts #40
Crisper: Protecting your Polymer app with CSP -- Polycasts #40
Chrome for Developers
59 How do I use Sass with Polymer? #AskPolymer -- Polycasts #41
How do I use Sass with Polymer? #AskPolymer -- Polycasts #41
Chrome for Developers
60 Colors – DevTools Tonight #0 (Pilot)
Colors – DevTools Tonight #0 (Pilot)
Chrome for Developers

The video teaches how to add structured data to a website using JavaScript, making it eligible for rich results in Google Search. It covers various implementation approaches and tools for testing and debugging.

Key Takeaways
  1. Understand what structured data is and its benefits
  2. Choose a markup format (JSON-LD, microdata, or RDFa)
  3. Implement structured data using vanilla JavaScript or a framework like React
  4. Use Google Tag Manager to create structured data
  5. Test and debug the implementation using the Rich Results Test and Google Search Console
💡 Implementing structured data with JavaScript can make a website eligible for rich results in Google Search, but it's essential to test and debug the implementation to ensure correctness.

Related AI Lessons

Up next
News At 10
Channels Television
Watch →