Duplicate JSON-LD scripts in head

后端 未结 1 860
南方客
南方客 2021-01-26 19:35

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

1条回答
  •  后悔当初
    2021-01-26 19:54

    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):

    
    
    
    

    (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.)

    0 讨论(0)
提交回复
热议问题