我正在尝试将 json 脚本添加到我的 Pug JS 文件中,该脚本是用于 SEO 的结构化数据。我的做法与使用
type="text/javascript"
处理 JavaScript 的方式相同,但它无法编译,并且不断出现错误。是语法问题吗?请告诉我我做错了什么,谢谢。
script(type="application/ld+json"{ "@context": "https://schema.org", "@graph": [ { "@type": "WebPage", "@id": "https://www.example.io/some-page/", "url": "https://www.example.io/some-page/", "name": "Access Example's Knowledge Base", "isPartOf": { "@id": "https://www.example.io/#website" })
Unexpected character : expected `=`
Details:
code: PUG:INVALID_KEY_CHARACTER
msg: Unexpected character : expected `=`
line: 14
column: 53
Syntax Error: Unexpected token
Details:
code: PUG:SYNTAX_ERROR
msg: Syntax Error: Unexpected token
line: 14
column: 38
试试这个:
script(type='application/ld+json').
{
"@context": "https://schema.org",
"@graph": [
{
"@type": "WebPage",
"@id": "https://www.example.io/some-page/",
"url": "https://www.example.io/some-page/",
"name": "Access Example's Knowledge Base",
"isPartOf": {
"@id": "https://www.example.io/#website"
}
}
]
}