JSON-LD标记中@graph关键字的应用是否正确?
你的@graph用法完全错误,给你修正方案
问题点:
- @graph是JSON-LD的顶级属性,不能嵌套在
ProductGroup这类类型里面,而且它的值必须是数组,不能是单个对象。 - 原代码还有JSON语法错误:
@graph对象末尾多了个逗号,会导致解析失败。 - 你想同时声明“Wire Rope”为
ProductGroup和Product并关联变体,根本不需要乱嵌套@graph,直接用顶级@graph数组放两个独立节点就行。
修正后的代码:
<script type="application/ld+json"> { "@context": "https://schema.org", "@graph": [ { "@type": "ProductGroup", "name": "Wire Rope", "aggregateRating": { "@type": "AggregateRating", "ratingValue": "4.9", "reviewCount": "19" }, "description": "Various types of wire ropes for different applications.", "hasVariant": [ { "@id": "#ss-wire-rope", "@type": "Product", "name": "Stainless Steel SS wire rope", "image": "https://sviboindustries.in/wp-content/uploads/2023/06/ss-wire-rope.jpg", "description": "The SS wire rope is a strong and flexible cable made of stainless steel wires twisted together, commonly used for various applications such as lifting, rigging, and suspension due to its durability and resistance to corrosion.", "aggregateRating": { "@type": "AggregateRating", "ratingValue": "4.9", "reviewCount": "16" } }, { "@id": "#pvc-wire-rope", "@type": "Product", "name": "PVC Coated wire rope", "image": "https://sviboindustries.in/wp-content/uploads/2023/05/pr-203.png", "description": "PVC coated wire rope is a type of cable consisting of stainless steel wires encased in a protective PVC (polyvinyl chloride) coating. This coating provides additional resistance to corrosion, abrasion, and weathering, making it suitable for outdoor and marine applications.", "aggregateRating": { "@type": "AggregateRating", "ratingValue": "4.7", "reviewCount": "21" } }, { "@id": "#galvanized-wire-rope", "@type": "Product", "name": "Galvanized wire rope", "image": "https://sviboindustries.in/wp-content/uploads/2023/05/galvanized-wire-rope-500x500-1.png", "description": "Galvanized wire rope is a cable made of steel wires that are coated with a layer of zinc through the process of galvanization.", "aggregateRating": { "@type": "AggregateRating", "ratingValue": "4.7", "reviewCount": "8" } }, { "@id": "#ungalvanized-wire-rope", "@type": "Product", "name": "Ungalvanized wire rope", "image": "https://sviboindustries.in/wp-content/uploads/2023/05/black-steel-wire-rope-500x500-1.jpg", "description": "Ungalvanized wire rope is a cable made of steel wires without a protective zinc coating.", "aggregateRating": { "@type": "AggregateRating", "ratingValue": "4.9", "reviewCount": "15" } } ] }, { "@type": "Product", "name": "Wire Rope", "aggregateRating": { "@type": "AggregateRating", "ratingValue": "4.9", "reviewCount": "19" }, "description": "Various types of wire ropes for different applications.", "hasVariant": [ {"@id": "#ss-wire-rope"}, {"@id": "#pvc-wire-rope"}, {"@id": "#galvanized-wire-rope"}, {"@id": "#ungalvanized-wire-rope"} ] } ] } </script>
额外优化建议:
- 给每个变体加
@id属性,在Product节点里直接引用ID关联变体,避免重复写冗余内容。 - 如果核心需求是展示产品组和变体,
ProductGroup本身就能承载产品组信息,不一定非要单独声明Product类型的主条目,除非需要主产品被搜索引擎单独识别。
内容的提问来源于stack exchange,提问作者ssc1234
相关产品推荐
相关产品推荐

