如何用 Schema.org 表示导航链接
How to represent navigation links with Schema.org
我有一个常规的投资组合网站(普通 HTML),该网站包含一个带有 »about«、»imprint« 和 »contact« 链接的导航,因此生成的站点地图是:
index
|
+-------+----+----+--------+
| | | |
about contact imprint projects
|
+-----+--+--+-----+
| | | |
A B C D
所以在 index
(/
) 页面上,我想像这样包含 JSON-LD:
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "WebSite",
…
…
}
</script>
"about"、"contact"、……的链接如何用Schema.org表示?会:
{
…
"@type": "WebSite",
"links":
[
{
"@type": "WebSite",
"@id": "https://…"
}
]
}
对吗?
您使用了 links
属性,它(给定您的 @context
)导致了 属性 URI http://schema.org/links
。但这不是有效的 Schema.org 属性,因此您不能使用它。
要将 WebPage
项与其 WebSite
相关联,您可以使用 hasPart
/isPartOf
属性:
{
"@context": "http://schema.org",
"@type": "WebSite",
"@id": "/#site",
"hasPart": [
{
"@type": "WebPage",
"@id": "/page-1"
},
{
"@type": "WebPage",
"@id": "/page-2"
}
]
}
{
"@context": "http://schema.org",
"@type": "WebPage",
"@id": "/page-1",
"isPartOf": {
"@type": "WebSite",
"@id": "/#site"
}
}
对于联系页面,您可以使用ContactPage
type. For the about page, you can use the AboutPage
type. Both are subtypes of WebPage
. Schema.org doesn’t offer a subtype for each possible type of page, of course; for pages that have no specific subtype defined, you can use the broad WebPage
type; in many cases, it’s also possible to either use ItemPage
or CollectionPage
。
如果要表示导航本身,可以使用 SiteNavigationElement
类型。
我有一个常规的投资组合网站(普通 HTML),该网站包含一个带有 »about«、»imprint« 和 »contact« 链接的导航,因此生成的站点地图是:
index
|
+-------+----+----+--------+
| | | |
about contact imprint projects
|
+-----+--+--+-----+
| | | |
A B C D
所以在 index
(/
) 页面上,我想像这样包含 JSON-LD:
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "WebSite",
…
…
}
</script>
"about"、"contact"、……的链接如何用Schema.org表示?会:
{
…
"@type": "WebSite",
"links":
[
{
"@type": "WebSite",
"@id": "https://…"
}
]
}
对吗?
您使用了 links
属性,它(给定您的 @context
)导致了 属性 URI http://schema.org/links
。但这不是有效的 Schema.org 属性,因此您不能使用它。
要将 WebPage
项与其 WebSite
相关联,您可以使用 hasPart
/isPartOf
属性:
{
"@context": "http://schema.org",
"@type": "WebSite",
"@id": "/#site",
"hasPart": [
{
"@type": "WebPage",
"@id": "/page-1"
},
{
"@type": "WebPage",
"@id": "/page-2"
}
]
}
{
"@context": "http://schema.org",
"@type": "WebPage",
"@id": "/page-1",
"isPartOf": {
"@type": "WebSite",
"@id": "/#site"
}
}
对于联系页面,您可以使用ContactPage
type. For the about page, you can use the AboutPage
type. Both are subtypes of WebPage
. Schema.org doesn’t offer a subtype for each possible type of page, of course; for pages that have no specific subtype defined, you can use the broad WebPage
type; in many cases, it’s also possible to either use ItemPage
or CollectionPage
。
如果要表示导航本身,可以使用 SiteNavigationElement
类型。