JSON-LD SiteNavigationElement:子页面架构无法识别 itemListElement 属性

问题描述 投票:0回答:1

我有一个问题,我正在尝试使用“SiteNavigationElement”类型方案为我的网页制作 JSON-LD 代码。

但是当我尝试验证它时。它被拒绝并收到 5 次警告。 这让我很好奇。因为一旦我有了一个没有子页面的一级 JSON-LD 代码,它就可以很好地验证。

但是当我添加子页面时它会生成警告。

从波兰语翻译过来,验证者说:

模式无法识别 itemListElement 属性(例如 schema.org)作为 SiteNavigationElement 对象的一部分。

我不知道如何解决这个问题。

<script type="application/ld+json">
{
    "@context": "https://schema.org",
    "@type": "SiteNavigationElement",
    "name": "Top Level Navigation",
    "mainEntity": [
        [
            {
                "@type": "SiteNavigationElement",
                "position": 1,
                "name": "home",
                "description": "TEMP DESCRIPTION",
                "url": "https://example.com/"
            },
            {
                "@type": "SiteNavigationElement",
                "position": 2,
                "name": "A very nice page",
                "description": "TEMP DESCRIPTION",
                "url": "https://example.com/about-the-page"
            },
            {
                "@type": "SiteNavigationElement",
                "position": 3,
                "name": "diensten",
                "description": "TEMP DESCRIPTION",
                "url": "https://example.com/all-services"
            },
            {
                "@type": "SiteNavigationElement",
                "position": 4,
                "name": "contact",
                "description": "TEMP DESCRIPTION",
                "url": "https://example.com/contact",
                "@context": "https://schema.org",
                "itemListElement": [
                    {
                        "@type": "SiteNavigationElement",
                        "position": 1,
                        "name": "Den Haag",
                        "description": "TEMP DESCRIPTION",
                        "url": "https://example.com/contact/den-haag"
                    },
                    {
                        "@type": "SiteNavigationElement",
                        "position": 2,
                        "name": "Haarlem",
                        "description": "TEMP DESCRIPTION",
                        "url": "https://example.com/contact/haarlem"
                    }
                ]
            },
            {
                "@type": "SiteNavigationElement",
                "position": 5,
                "name": "over ons",
                "description": "TEMP DESCRIPTION",
                "url": "https://example.com/about-us",
                "@context": "https://schema.org",
                "itemListElement": [
                    {
                        "@type": "SiteNavigationElement",
                        "position": 1,
                        "name": "A very nice page",
                        "description": "TEMP DESCRIPTION",
                        "url": "https://example.com/about-the-page"
                    },
                    {
                        "@type": "SiteNavigationElement",
                        "position": 2,
                        "name": "Where we are good at",
                        "description": "TEMP DESCRIPTION",
                        "url": "https://example.com/about-us/we-are-good-at"
                    }
                ]
            },
            {
                "@type": "SiteNavigationElement",
                "name": "Who are we and what we are good at",
                "description": "TEMP DESCRIPTION",
                "@context": "https://schema.org",
                "itemListElement": [
                    {
                        "@type": "SiteNavigationElement",
                        "position": 1,
                        "name": "Alle diensten",
                        "description": "TEMP DESCRIPTION",
                        "url": "https://example.com/who-are-we/all-services"
                    }
                ]
            },
            {
                "@type": "SiteNavigationElement",
                "position": 6,
                "name": "A very simple explanation about everthing",
                "description": "TEMP DESCRIPTION",
                "url": "https://example.com/a-simple-explanation"
            },
            {
                "@type": "SiteNavigationElement",
                "position": 7,
                "name": "Nikola",
                "description": "TEMP DESCRIPTION",
                "url": "https://example.com/nikola"
            },
            {
                "@type": "SiteNavigationElement",
                "position": 8,
                "name": "Contact",
                "description": "TEMP DESCRIPTION",
                "url": "https://example.com/testcontact"
            },
            {
                "@type": "SiteNavigationElement",
                "position": 9,
                "name": "Our projects",
                "description": "TEMP DESCRIPTION",
                "url": "https://example.com/our-projects"
            },
            {
                "@type": "SiteNavigationElement",
                "position": 10,
                "name": "sddsds",
                "description": "TEMP DESCRIPTION",
                "url": "https://example.com/this-works-great"
            },
            {
                "@type": "SiteNavigationElement",
                "position": 11,
                "name": "Building your house",
                "description": "TEMP DESCRIPTION",
                "url": "https://example.com/building-your-house"
            },
            {
                "@type": "SiteNavigationElement",
                "position": 12,
                "name": "By bike",
                "description": "TEMP DESCRIPTION",
                "url": "https://example.com/bike"
            }
        ]
    ]
}
</script>

一旦我启动子元素,它基本上就会给我一个警告。 但我想知道我在那里做错了什么?

    {
        "@type": "SiteNavigationElement",
        "position": 4,
        "name": "contact",
        "description": "TEMP DESCRIPTION",
        "url": "https://example.com/contact",
        "@context": "https://schema.org",
        "itemListElement": [
            {
                "@type": "SiteNavigationElement",
                "position": 1,
                "name": "Den Haag",
                "description": "TEMP DESCRIPTION",
                "url": "https://example.com/contact/den-haag"
            },
            {
                "@type": "SiteNavigationElement",
                "position": 2,
                "name": "Haarlem",
                "description": "TEMP DESCRIPTION",
                "url": "https://example.com/contact/haarlem"
            }
        ]
    },

我确实重新开始了这个职位。我再次设置了上下文。但同样...没有子页面/子页面它效果很好。

没有子页面且没有警告的工作示例

<script type="application/ld+json">
{
    "@context": "https://schema.org",
    "@type": "SiteNavigationElement",
    "name": "Top Level Navigation",
    "mainEntity": [
        [
            {
                "@type": "SiteNavigationElement",
                "position": 1,
                "name": "home",
                "description": "TEMP DESCRIPTION",
                "url": "https://example.com/"
            },
            {
                "@type": "SiteNavigationElement",
                "position": 2,
                "name": "A very nice page",
                "description": "TEMP DESCRIPTION",
                "url": "https://example.com/about-the-page"
            },
            {
                "@type": "SiteNavigationElement",
                "position": 3,
                "name": "diensten",
                "description": "TEMP DESCRIPTION",
                "url": "https://example.com/all-services"
            },
            {
                "@type": "SiteNavigationElement",
                "position": 4,
                "name": "A test page x 0",
                "description": "TEMP DESCRIPTION",
                "url": "https://example.com/test-page-x-0"
            },
            {
                "@type": "SiteNavigationElement",
                "position": 5,
                "name": "A test page x",
                "description": "TEMP DESCRIPTION",
                "url": "https://example.com/test-page-x"
            },
            {
                "@type": "SiteNavigationElement",
                "position": 6,
                "name": "A very simple explanation about everthing",
                "description": "TEMP DESCRIPTION",
                "url": "https://example.com/a-simple-explanation"
            },
            {
                "@type": "SiteNavigationElement",
                "position": 7,
                "name": "Nikola",
                "description": "TEMP DESCRIPTION",
                "url": "https://example.com/nikola"
            },
            {
                "@type": "SiteNavigationElement",
                "position": 8,
                "name": "Contact",
                "description": "TEMP DESCRIPTION",
                "url": "https://example.com/testcontact"
            },
            {
                "@type": "SiteNavigationElement",
                "position": 9,
                "name": "Our projects",
                "description": "TEMP DESCRIPTION",
                "url": "https://example.com/our-projects"
            },
            {
                "@type": "SiteNavigationElement",
                "position": 10,
                "name": "sddsds",
                "description": "TEMP DESCRIPTION",
                "url": "https://example.com/this-works-great"
            },
            {
                "@type": "SiteNavigationElement",
                "position": 11,
                "name": "Building your house",
                "description": "TEMP DESCRIPTION",
                "url": "https://example.com/building-your-house"
            },
            {
                "@type": "SiteNavigationElement",
                "position": 12,
                "name": "By bike",
                "description": "TEMP DESCRIPTION",
                "url": "https://example.com/bike"
            }
        ]
    ]
}
</script>

warnings schema.org json-ld
1个回答
0
投票

一旦我启动子元素,它基本上就会给我一个警告。但 我想知道我在那里做错了什么?

您在不支持此属性的类型

itemListElement
中嵌套了一个子元素,例如属性
SiteNavigationElement
。要解决此问题,请使用类型 SiteNavigationElement 可用的属性。

© www.soinside.com 2019 - 2024. All rights reserved.