首页 > 解决方案 > javascript 创建的 JSON-LD 不是结构化数据

问题描述

我正在尝试使用 javascript 为我的网站自动生成 json-ld 结构化数据。一切都很好,直到我从工具中检查,在 javascript 中生成的 json-ld 代码没有出现在测试表上。当我继续在 chrome 上查看源代码时,它不会显示 json-ld 代码。

你可以在这里看到它

代码是打击

<script id='myJSONID' type='application/ld+json'></script>
<script type='text/javascript'>
//<![CDATA[
$('#myJSONID').text(function() {
    return JSON.stringify({
        "@context":"https://schema.org",
        "@type":"Review",
        "author": {
            "@type":"Person",
            "name":"Nhà Gò Vấp đẹp",
            "sameAs":"https://www.blogger.com/profile/14170245093404020455"
        },
        "url": "<data:blog.canonicalUrl/>",
        "datePublished": "<data:post.dateHeader/>",
        "publisher": {
            "@type":"Organization",
            "name":"" + document.title,
            "sameAs":"<data:blog.homepageUrl/>"
        },
        "description":"" + document.getElementsByName("description")[0].content,
        "inLanguage":"vi",
        "itemReviewed": {
            "@type":"Product",
            "name": "<data:blog.pageName/>",
            "description":"" + document.getElementsByName("description")[0].content,
            "sameAs": "<data:blog.canonicalUrl/>",
            "image": "<data:blog.postImageThumbnailUrl/>",
            "aggregateRating": {
                "@type": "AggregateRating",
                "ratingValue": "5",
                "bestRating": "5",
                "ratingCount": "20"
             }
        }
    });
});
//]]>
</script>

我想请人看看我在上面的 javascript 代码中是否做错了什么?如果是这样,为什么谷歌不识别这个 json-ld 数据?

提前致谢!

标签: javascripthtmljsonseo

解决方案


推荐阅读