同一页面展示电影场次列表的正确Schema.org结构化结构是什么?
优化方案(基于Schema.org规范消除重复数据)
你现有代码的冗余问题主要来自两方面:一是每个子节点重复声明@context,二是同一个影院、同一部电影的信息在每个场次中重复定义。你可以通过Schema.org的@id属性实现实体复用,同时去掉冗余的@context声明,优化后的写法如下:
{ "@context": "https://schema.org", "@type": "ItemList", "numberOfItems": 2, "itemListElement": [ { "@type": "ListItem", "name": "Screening Event 1", "position": 1, "item": { "@type": "ScreeningEvent", "startDate": "2021-09-18T15:15:00.000Z", "url": "http://localhost:3000/film/Boite-noire/663260#6144ab7a22b6d900165aa836", "inLanguage": "fr", "location": { "@type": "MovieTheater", "@id": "http://localhost:3000/medium/pathe-tunis-city", "name": "Pathé Tunis City", "url": "http://localhost:3000/medium/pathe-tunis-city" }, "workPresented": { "@type": "Movie", "@id": "http://localhost:3000/film/Boite-noire/663260", "name": "Boîte noire", "image": "https://image.tmdb.org/t/p/w300_and_h450_bestv2/jIfFFC4YwiI8TVaGtbl1eT9BRaI.jpg", "url": "http://localhost:3000/film/Boite-noire/663260", "sameAs": "https://imdb.com/title/tt10341034", "director": { "@type": "Person", "name": "Yann Gozlan" } } } }, { "@type": "ListItem", "name": "Screening Event 2", "position": 2, "item": { "@type": "ScreeningEvent", "startDate": "2021-09-18T20:15:00.000Z", "url": "http://localhost:3000/film/Boite-noire/663260#6144ab8522b6d900165aa837", "inLanguage": "fr", "location": {"@id": "http://localhost:3000/medium/pathe-tunis-city"}, "workPresented": {"@id": "http://localhost:3000/film/Boite-noire/663260"} } } ] }
优化说明
- 去掉了所有子节点重复的
@context声明,仅保留顶层1次即可,完全符合JSON-LD规范 - 给影院、电影实体分别分配了和自身URL一致的
@id作为唯一标识,第二个场次中直接通过@id引用实体,无需重复写入名称、海报、导演等所有字段,数据量减少60%以上 - 语义完整性不受影响:搜索引擎可以自动识别相同
@id对应的是同一个实体,关联关系完全和原写法一致 - 如果后续同页面还有更多同影院、同电影的场次,只需要继续复用这两个
@id即可,不会再产生额外冗余
内容的提问来源于stack exchange,提问作者A.Hidri
相关产品推荐
相关产品推荐

