Google and Bing now both support semantic markup and structured data via JSON-LD - in fact, Google now recommends JSON-LD as the preferred method for marking up data, for both organic and paid search features. Implementing markup via JSON-LD can be a snap for a small or simple site, but when you’ve got multiple sites, hundreds of locations, or thousands of products, it can still be a slog to implement that JSON-LD statically for each page.
27. Function Expression Breakdown
@ruthburr #searchlove
(function(){
var data = {
"@context": "http://schema.org",
"@type": "blogPosting",
"name": {{dataPoint — Entry Title}},
"description": {{dataPoint — Blog Post Description}},
...
}
var script = document.createElement('script');
script.type = "application/ld+json";
script.innerHTML = JSON.stringify(data);
document.getElementsByTagName('head')[0].appendChild(script);
})(document);
Do this right away –
don’t worry about
the other JS on the
page
28. Function Expression Breakdown
@ruthburr #searchlove
(function(){
var data = {
"@context": "http://schema.org",
"@type": "blogPosting",
"name": {{dataPoint — Entry Title}},
"description": {{dataPoint — Blog Post Description}},
...
}
var script = document.createElement('script');
script.type = "application/ld+json";
script.innerHTML = JSON.stringify(data);
document.getElementsByTagName('head')[0].appendChild(script);
})(document);
A JavaScript Object
named “data” that
contains all our
variables in double
curlies
29. Function Expression Breakdown
@ruthburr #searchlove
(function(){
var data = {
"@context": "http://schema.org",
"@type": "blogPosting",
"name": {{dataPoint — Entry Title}},
"description": {{dataPoint — Blog Post Description}},
...
}
var script = document.createElement('script');
script.type = "application/ld+json";
script.innerHTML = JSON.stringify(data);
document.getElementsByTagName('head')[0].appendChild(script);
})(document);
Create a new
<script> tag
It’s JSON-LD, not
regular JavaScript
30. Function Expression Breakdown
@ruthburr #searchlove
(function(){
var data = {
"@context": "http://schema.org",
"@type": "blogPosting",
"name": {{dataPoint — Entry Title}},
"description": {{dataPoint — Blog Post Description}},
...
}
var script = document.createElement('script');
script.type = "application/ld+json";
script.innerHTML = JSON.stringify(data);
document.getElementsByTagName('head')[0].appendChild(script);
})(document);
Inside our new
<script> tag, put
all the values from
“data” in a JSON-LD
block
31. Function Expression Breakdown
@ruthburr #searchlove
(function(){
var data = {
"@context": "http://schema.org",
"@type": "blogPosting",
"name": {{dataPoint — Entry Title}},
"description": {{dataPoint — Blog Post Description}},
...
}
var script = document.createElement('script');
script.type = "application/ld+json";
script.innerHTML = JSON.stringify(data);
document.getElementsByTagName('head')[0].appendChild(script);
})(document);
Find the <head> of
the page, and plop
that script on in
there