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