What exactly are pointers in Schema.org and how to use them with JSON-LD? - schema.org

The schema.org docs refer sometimes to "pointers". E.g. Product schema has the property isSimilarTo.
I do understand, that I could use a Productor a Service directly. E.g.:
<script type="application/ld+json">
{
"#context": "http://schema.org/",
"#type": "Product",
"name": "BMW",
"isSimilarTo": {
"#type": "Product",
"name": "Mercedes Benz"
},
"offers": {
"#type": "Offer",
"priceCurrency": "EUR",
"price": "100000.00"
}
}
</script>
Is this the only and the correct way using and interpreting the term 'pointer' in this context? For a pointer, I would rather expect some value (an ID or an URL or similar) just pointing to another product or service.

Your example is correct, and it follows Schema.org’s recommendation for the expected value of the isSimilarTo property. But Schema.org allows URI values for each property, even for those that don’t explicitly list URL as expected value.
So you could also use:
"isSimilarTo": {
"#id": "https://example.com/products/mercedes-benz#this"
},
Note that consumers (like Google) don’t necessarily follow these references. You could also use both ways: provide the data (or some of it) on the current page, and refer to the item’s URI:
"isSimilarTo": {
"#id": "https://example.com/products/mercedes-benz#this",
"#type": "Product",
"name": "Mercedes Benz",
"url": "https://example.com/products/mercedes-benz"
},

Related

What is the correct use of mainEntityOfPage schema

I am writing structured data for a magazine. I got this under the Article type:
"mainEntityOfPage": {
"#type": "WebPage",
"#id": " https://www.example.com/category" //category of the article
},
I thought I would mark the category of the article using this. Is this the correct way of using mainEntityOfPage?
No, the value should be the WebPage dedicated to the Article. Both items would typically have the same url, but possibly different #id values (see URL of page vs. post).
{
"#context": "http://schema.org",
"#type": "Article",
"#id": "/articles/42#this",
"url": "/articles/42",
"mainEntityOfPage": {
"#type": "ItemPage",
"#id": "/articles/42",
"url": "/articles/42"
}
}
It might become clearer when looking at the inverse property mainEntity. You would have a WebPage for the current page and provide the mainEntity property to convey what the primary entity on this page is:
{
"#context": "http://schema.org",
"#type": "ItemPage",
"mainEntity": {
"#type": "Article"
}
}
When using mainEntityOfPage instead of mainEntity, you simply switch subject and object.

Defining Schema.org JSON-LD for my Multi-language Web application

I am building a web application for product comparison. The website has a structure like so:
http://example.com
http://example.com/fr/compare/
http://example.com/es/compare/
etc..
The main page is in English.
I want to insert Schema.org for each of the pages and I've construed this schema. Written in square brackets are what I intend to put as value later on.
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#id": "[canonical-url-for-specific-language]#webapp",
"#type": "WebApplication",
"name": "[Product Comparison Title in specific language]",
"url": "[canonica url for specific language]",
"applicationCategory": "Utility",
"applicationSubCategory": "Product Comparison",
"about": "[page-description]",
"browserRequirements": "Requires JavaScript. Requires HTML5.",
"softwareVersion": "1.0.0",
"screenshot": "[image-url]",
"inLanguage": "[language-code]",
"softwareHelp": {
"#type": "CreativeWork",
"url": "[link-to-how-to-page-for-specific-language]"
},
"operatingSystem": "All"
}
</script>
How can I construct this JSON-LD well to work for my specific website.
If you use structured data for a home page that has a language selector, then the markup can be similar to the following:
{
"#context": "https://schema.org",
"#id": "[canonical-url-for-specific-language]#webapp",
"#type": "WebApplication",
"name": "[Product Comparison Title in specific language]",
"url": "[canonica url for specific language]",
"applicationCategory": "Utility",
"applicationSubCategory": "Product Comparison",
"about": "[page-description]",
"browserRequirements": "Requires JavaScript. Requires HTML5.",
"softwareVersion": "1.0.0",
"screenshot": "[image-url]",
"inLanguage":[{
"#type": "Language",
"name": "English",
"alternateName": "en",
"additionalType":"https://www.loc.gov/standards/iso639-2/php/code_list.php",
"sameAs":"https://en.wikipedia.org/wiki/English_language"
},
{
"#type": "Language",
"name": "Spanish",
"alternateName": "es",
"additionalType":"https://www.loc.gov/standards/iso639-2/php/code_list.php",
"sameAs":"https://en.wikipedia.org/wiki/Spanish_language"
}],
"softwareHelp": {
"#type": "CreativeWork",
"name":"Customer Service and Support",
"url": [
"https://examples.com/en/help.html",
"https://examples.com/es/help.html"
]
},
"operatingSystem": "All"
}
Note that I have here used for each language two identifiers with the properties sameAs and additionalType.
If the web page is with one particular language, then just delete the part of the markup for the unnecessary language and the square brackets.
Check out this markup on the Google testing tool and note that there are two warnings that are useful to fix.

Schema.org Character's URL for a PerformanceRole's entry

From Schema.org PerformanceRole JSON-LD example:
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "Movie",
"name": "Ghostbusters",
"sameAs": "http://en.wikipedia.org/wiki/Ghostbusters",
"actor": {
"#type": "PerformanceRole",
"actor": {
"#type": "Person",
"name": "Bill Murray"
},
"characterName": "Dr. Peter Venkman"
}
}
</script>
I can add a sameAs for each Person and thus have a reference/profile URL for each actor/actress involved with the movie.
Could I have the same for the Character performed by the actors?
In the example above Dr. Peter Venkman could have a link to something like this, a page with information specifically about that Character, regardless of the actor/actress interpreting him.
But, as far as I know, the characterName Property only accepts raw text.

List of citations doesn’t get recognized by SDTT

I am trying to structure a list of citations properly using JSON-LD and just cannot get Google’s SDTT to recognize the items.
I have simplified the data here. Can anyone tell me what it is that is not allowing the SDTT to see the item?
<script type="application/ld+json">
"#context": "http://schema.org/",
"#type": "ItemList" {
"#type": "citation" {
"#type" : "periodical" {
"name": "Log of Mystic Seaport (1948-2003; Vols. 1-54)"
},
"#type": "vehicle" {
"name": "Mary Celeste",
"category": "brig",
"date": "1905",
"nationality": "American",
"weight": "",
"id": ""
}
}
}
}
</script>
Errors
In JSON-LD, the curly braces always have to come in pairs:
You have four {, but five }.
Schema.org terms are case-sensitive:
There is no periodical, but Periodical.
There is no vehicle, but Vehicle.
JSON-LD’s #type can only be used for types, not for properties:
citation is not a type, but a property.
A #type statement can’t be followed by a {:
"#type": "ItemList" { (and the other occurrences) is invalid. It seems that you want to use a property here in addition.
For a Schema.org type, you should only use properties that are defined for it:
The Vehicle type doesn’t define the properties date, nationality, nor id (there is no such property in Schema.org).
ItemList entries
You need to use the itemListElement property for providing the list entries:
{
"#context": "http://schema.org/",
"#type": "ItemList",
"itemListElement": [
{
"#type": "CreativeWork"
},
{
"#type": "CreativeWork"
},
{
"#type": "CreativeWork"
}
]
}

ListItem Schema [schema.org/ItemList] error: "All values provided for url must have the same domain."

I am facing issue with this ListItem schema validation on https://search.google.com/structured-data/testing-tool/u/0/
Getting error
All values provided for url must have the same domain.
I have provided same domain in every URL field.
{
"#context": "http://schema.org",
"#type": "ItemList",
"name": "Tech News",
"url": "http://m.gadgetsnow.com/tech-news",
"itemListElement": [
{
"#type": "ListItem",
"position": "1",
"url": "http://m.gadgetsnow.com/tech-news/are-tvs-going-out-of-fashion/articleshow/58375579.cms",
"name": "Are TVs going out of fashion?",
"image": {
"#type": "ImageObject",
"contentUrl": "http://m.gadgetsnow.com/photo/58375579.cms",
"width": "360",
"height": "270",
"url": "http://m.gadgetsnow.com/photo/58375579.cms"
}
},
{
"#type": "ListItem",
"position": "2",
"url": "http://m.gadgetsnow.com/tech-news/reliance-jio-discounts-are-not-going-anywhere-for-now-heres-why/articleshow/58374335.cms",
"name": "Reliance Jio discounts are not going anywhere for now, here's why",
"image": {
"#type": "ImageObject",
"contentUrl": "http://m.gadgetsnow.com/photo/58374335.cms",
"width": "360",
"height": "270",
"url": "http://m.gadgetsnow.com/photo/58374335.cms"
}
}
]
}
You may try using the correct version of ItemList. There are Separately and Combined marked up ItemLists as referred here.
If your items are on the same page, please use the version with items inside, the Combined one.
Otherwise, if you point to different pages inside and your items are not on one page, please DON’T put item element with type and other
description inside, the Separately marked up one.
Additional references:
Error in Google SDTT: "All values provided for url must point to the same page."
Schema.org and ContactPoint use with validation failure: “All values provided for http://www.example.com/ must have the same domain.”
There are no bugs. Be careful if the validator gives errors, a big chance that rich snippets will not work.
So what's the problem? The first thing to note is that in the ListItem object, either url or item can be used. As the schema.org documentation says, item is used for:
an artist’s list of data artists (e.g. an 'artist' in a list of 'artists')
And the most important thing that I noticed: if you use item and you want the scheme to be correct, then the domain and its parts should be the same in all ListItem, but the anchors are different, which are separated from the url using the # symbol. Google gives a specific example:
<script type="application/ld+json">
{
"#context": "https://schema.org",
"#type": "ItemList",
"itemListElement": [
{
"#type": "ListItem",
"position": "1",
"item": {
"#context": "https://schema.org/",
"#type": "Recipe",
"url": "http://example.com/big_list_of_recipes#cherry_pie",
}
},
{
"#type": "ListItem",
"position": "2",
"item": {
"#context": "https://schema.org/",
"#type": "Recipe",
"url": "http://example.com/big_list_of_recipes#coffee_cake",
...
}
}
]
}
</script>
As you can see in the list, the same URL is used http://example.com/big_list_of_recipe, but different anchors: #cherry_pie and #coffee_cake.
But still it is not clarity how to specify the URL, which is a separate page for the thing.