gpt4 book ai didi

navigation - 如何使用 JSON-LD 创建 SiteNavigationElement?

转载 作者:行者123 更新时间:2023-12-05 00:55:36 25 4
gpt4 key购买 nike

我正在尝试使用 SiteNavigationElement从 Schema.org 输入。 HTML 是动态生成的,因此我无法对其进行编辑。所以 JSON-LD 是我唯一的选择。

我想要一个 SiteNavigationElement 下的所有导航元素目的。

我已附加所需的输出作为屏幕截图:

Desired structure output

最佳答案

这是如何做到的:

<script type="application/ld+json">
{
"@context": "https://schema.org",
"@graph":
[
{
"@context": "https://schema.org",
"@type":"SiteNavigationElement",
"@id":"#table-of-contents",
"name": "Section 1",
"url": "https://www.example.com/page#toc-1"
},
{
"@context": "https://schema.org",
"@type":"SiteNavigationElement",
"@id":"#table-of-contents",
"name": "Section 2",
"url": "https://www.example.com/page#toc-2"
},
{
"@context": "https://schema.org",
"@type":"SiteNavigationElement",
"@id":"#table-of-contents",
"name": "Section 3",
"url": "https://www.example.com/page#toc-3"
},
{
"@context": "https://schema.org",
"@type":"SiteNavigationElement",
"@id":"#pagination",
"name": "Previous page",
"url": "https://www.example.com/page1"
},
{
"@context": "https://schema.org",
"@type":"SiteNavigationElement",
"@id":"#pagination",
"name": "Next page",
"url": "https://www.example.com/page2"
}
]
}
</script>

这段代码会像 this example 中看到的那样出来.

关于navigation - 如何使用 JSON-LD 创建 SiteNavigationElement?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37813757/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com