How to properly use mainEntityOfPage for a blog details page? - blogs

I've read several answers as to what mainEntityOfPage is and how to use it, and each one was more confusing than the last.
So my question is specific; I have a website which contains a blog section. On the blog details page I want to use structured data in JSON-LD format.
My question: would my mainEntityOfPage be WebPage or BlogPosting?
Should I use this:
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "WebPage",
"mainEntityOfPage": {
"#type": "BlogPosting",
}
}
</script>
or this:
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "BlogPosting",
"mainEntityOfPage": {
"#type": "WebPage",
}
}
</script>
I'm thinking the mainEntityOfPage is BlogPosting, so first example, yes? Or do I still have it all wrong?

The definition of mainEntityOfPage is:
Indicates a page (or other CreativeWork) for which this thing is the main entity being described.
The main entity on a blog post page is the blog post, not the page. So, the second snippet is correct:
{
"#context": "http://schema.org",
"#type": "BlogPosting",
"mainEntityOfPage": {
"#type": "WebPage"
}
}
If you want to use the first snippet (so that WebPage is the top-level item), you have to use mainEntity instead of mainEntityOfPage:
{
"#context": "http://schema.org",
"#type": "WebPage",
"mainEntity": {
"#type": "BlogPosting"
}
}
Note 1: mainEntity and mainEntityOfPage are inverse properties, so these two snippets mean the same.
Note 2: Maybe it helps to read it as "is the mainEntityOfPage", and "has mainEntity".
Note 3: You can use ItemPage (instead of WebPage) on the blog post pages.

Related

What is the correct way to nest Schema.org Property Types inside an Object Type in JSON-LD

Question:
How to nest a Schema.org property types inside an Object Type in a JSON-LD code?
Context:
I have a website with pages about the biography of persons. I have a validated JSON-LD code for the Schema.org Person Object Type.
I want to expand the code to include the persons that came before and after a person in a certain role. For example, if the page is about a mayor of a city, I want to add the previous and following mayors.
The closest properties I could find are follows for the previous mayor (link) and followee (link) for the following mayor.
The Problem:
The property follows was validated with no problems, but followee gave an error if placed directly under the Person type as it requires a FollowAction type.
The property #followee is not recognized by Google for an object of type Person.
Workaround Tried:
I tried to nest the code, but I could not do this successfully.
For example:
<script type="application/ld+json">
{
"#context": "http://schema.org/",
"#type": "Person",
"name": "john Citizen",
{
"#context": "http://schema.org/",
"#type": "FollowAction",
"followee": {
"#type": "Person",
"name": "Steve"
}
}
}
</script>
I tired several other variations, but all led to errors. Are there any feasible correction to the code, or alternative ways to achieve the goal?
As I mentioned in the comment, I don't think follows or FollowAction are appropriate for your use.
For academic purposes, there is a way to mark up FollowAction inside a person. As FollowAction can reference a Person via it's agent, but not the other way around, you can use the reverse property to indicate a kind of backward reference:
<script type="application/ld+json">
{
"#context": "http://schema.org/",
"#type": "Person",
"name": "john Citizen",
"#reverse": {
"agent":
{
"#type": "FollowAction",
"followee": {
"#type": "Person",
"name": "Steve"
}
}
}
}
</script>

Proper Schema.org markup for product reviews - that are blog posts

What's the proper Schema.org JSON-LD for a blog post / article that is solely meant to be a review for a product? Example of a practical usage that's ubiqutous on the web: I own a website that has a blog writing reviews and providing affiliate links (for example Amazon).
Technically, this is a Product, it's a Review, and obviously it's an Article (BlogPosting?).
On the Product you can nest the Review structure. So, this seems to be more focused with the pages content and this is the one I would assume is to be used. But, it is still an article and technically the site doesn't offer the product itself making the Product type seem incorrect.
So how exactly are you supposed to handle affiliate markup like this for blog sites without getting potentially dinged for marking up misleading information?
It depends on how expressive you want to be. For consumers interested in reviews, the first snippet would typically be all they need, as it’s likely not relevant to them if the review is published as blog post, as article, as forum post etc.
The minimum would be a Review with itemReviewed:
{
"#context": "https://schema.org/",
"#type": "Review",
"itemReviewed": {
"#type": "Product"
}
}
If you want to convey that the review is published as a blog post, you could use BlogPosting in addition:
{
"#context": "https://schema.org/",
"#type": ["Review", "BlogPosting"],
"itemReviewed": {
"#type": "Product"
}
}
If the BlogPosting consists of more than just the Review, but the Review is the primary content, you could use mainEntity with separate entities (and if it’s not the primary entity, you could use hasPart instead):
{
"#context": "https://schema.org/",
"#type": "BlogPosting",
"mainEntity": {
"#type": "Review",
"itemReviewed": {
"#type": "Product"
}
}
}
And if you want to provide data about the web page which contains the blog posting which is/contains the review, you could use ItemPage with mainEntity:
{
"#context": "https://schema.org/",
"#type": "ItemPage",
"mainEntity": {
"#type": ["Review", "BlogPosting"],
"itemReviewed": {
"#type": "Product"
}
}
}
{
"#context": "https://schema.org/",
"#type": "ItemPage",
"mainEntity": {
"#type": "BlogPosting",
"mainEntity": {
"#type": "Review",
"itemReviewed": {
"#type": "Product"
}
}
}
}

Duplicate JSON-LD scripts in head

I have to inject multiple script elements for JSON-LD data into the head of my application, all pertaining to the same #type. This is due to pulling in different fields from different data source.
Will this duplication cause any problems?
<script type="application/ld+json">
{
"#type": "Organisation",
"name": "John Smith"
}
</script>
<script type="application/ld+json">
{
"#type": "Organisation",
"city": "London"
}
</script>
I'm hoping this will be translated by Google as simply:
<script type="application/ld+json">
{
"#type": "Organisation",
"name": "John Smith",
"city": "London"
}
</script>
Is that right?
Consumers can’t/shouldn’t assume that these JSON objects describe the same thing. (Think of a web page with information about many different organizations: it would of course be wrong to assume that they are the same organization.)
JSON-LD allows you to specify that the things described in different objects are identical: give them the same #id value.
#id takes an IRI which acts as identifier (it’s useful to provide them for many reasons).
See Node Identifiers in the JSON-LD spec.
So it could look like this (using Schema.org instead of your custom vocabulary):
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "Organization",
"#id": "/organizations/42#this",
"name": "ACME"
}
</script>
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "Organization",
"#id": "/organizations/42#this",
"description": "…"
}
</script>
(The relative URL /organizations/42#this would represent the organization itself. It’s best practice then to provide this JSON-LD as well your information about the organization under /organizations/42.)

JSON-LD format for WebPage and BlogPosting

I have a medic weblog. My first page only has some data and top posts.
So I use this:
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "WebPage",
"name": "website name",
"description": "website description",
"publisher": {
"#type": "WebPageMedic",
"name": "my company name"
}
}
</script>
Now for another page, how can I write JSON-LD format?
I try this:
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "WebPage",
"name": "website name",
"description": "website description",
"publisher": {
"#type": "WebPageMedic",
"name": "my company name"
},
"mainEntity":{
"#type":"BlogPosting",
"headline":"BlogPosting",
"datePublished":"2015-03-09T13:08:00-07:00",
"articleBody": "articleBody"
}
}
</script>
I think I must write website information (WebPage) in all pages and then in mainEntity I can write BlogPosting and other things.
Am I right?
Yes, that is an appropriate structure if you want to have a WebPage item for every page (which is not necessary, but can be useful).
For a page that has multiple blog posts (in which case you might want to use CollectionPage), you could use a Blog item or an ItemList item as main entity. Another option is to use the hasPart property. See an example with mainEntity ItemList.
Notes about your example:
The properties of WebPage should be about the page, not about the site. You used "website name" and "website description". If you want to state something about your site, you can use the WebSite type.
There is no WebPageMedic type. You’ll probably want to use Organization or one of its sub-types, e.g., MedicalBusiness.

Schema.org - JSON-LD For External Sites?

I have some Schema.org JSON-LD like:
<script type='application/ld+json'>
{
"#context": "http://www.schema.org",
"#type": "WebSite",
"name": "Name",
"alternateName": "Alt Name",
"url": "http://Website.com"
}
</script>
And i have a website with pages where i list other peoples websites with a URL and a bit of info text.
Could i add the Schema.org JSON-LD data for all the external websites? like:
"name": "External Website 001",
Or does does it have to be used only once for my own website details on the main page etc?
If you want to say something about another website, it’s perfectly fine to use the WebSite type. Schema.org types are not required to be exclusively about your own things.
Let’s say you are reviewing the other website. Then you could use something like:
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "Review",
"url": "/reviews/acme-website",
"itemReviewed":
{
"#type": "WebSite",
"name": "ACME",
"url": "http://acme.example.com/"
}
}
</script>
If it’s not a review, but an article about the site, you could use Article (instead of Review) and its about property (instead of itemReviewed).