如何通过itemid关联Schema中ImageObject与外部Person对象?
解决Schema.org结构化数据重复声明问题的最优方案
你的问题根源在于重复实例化了同一个Person对象——在ImageObject的creator字段中,你额外添加了itemscope和itemtype,相当于重新定义了一遍该Person实例,这才触发了重复声明提示。
直接用link元素替代meta来关联已有的Person实例即可,既能通过W3C验证,又能让Schema.org正确识别对象关联:
<div itemtype="https://schema.org/Person" itemscope="" itemid="https://website.com/name/#profile"> <meta itemprop="name" content="MyName"> </div> <div itemtype="https://schema.org/ImageObject" itemscope=""> <link itemprop="url" href="https://website.com/img.jpg"> <link itemprop="creator" href="https://website.com/name/#profile"> </div>
核心逻辑:当需要引用一个已通过itemid定义好的Schema对象时,用link元素的href指向该itemid即可,无需再添加itemscope和itemtype。这种写法会被解析为对已有对象的引用,而非新对象的声明,完美解决重复提示问题,同时完全符合W3C规范。
内容的提问来源于stack exchange,提问作者Timur
相关产品推荐
相关产品推荐

