2

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?

user3654045
  • 77
  • 1
  • 12

1 Answers1

2

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.

unor
  • 92,415
  • 26
  • 211
  • 360
  • In the 1st code snippet you provided, is the '@id' required, if it's a leaf? – Ethan Jun 05 '19 at 21:22
  • 1
    @Ethan: It’s never required. It’s "just" a good practice to provide `@id` for every item, as it allows others to say something about this item ([Linked Data](https://en.wikipedia.org/wiki/Linked_data) / [Semantic Web](https://en.wikipedia.org/wiki/Semantic_Web)). – unor Jun 06 '19 at 14:23
  • Thanks for answering and the links. – Ethan Jun 06 '19 at 16:59