Seo 是否仍然可以使用未内联的JSON-LD模式
是否可以使用JSON-LD而不在HTML中包含Seo 是否仍然可以使用未内联的JSON-LD模式,seo,schema.org,content-security-policy,json-ld,Seo,Schema.org,Content Security Policy,Json Ld,是否可以使用JSON-LD而不在HTML中包含脚本内联,但仍然让Google(&other)spider找到它?环顾四周,我看到了一些相互矛盾的信息 如果这是JSON-LD文件: <script type="application/ld+json"> { "@context" : "http://schema.org", "@type" : "WebSite", "name" : "Example Site", "alt
脚本
内联,但仍然让Google(&other)spider找到它?环顾四周,我看到了一些相互矛盾的信息
如果这是JSON-LD文件:
<script type="application/ld+json">
{
"@context" : "http://schema.org",
"@type" : "WebSite",
"name" : "Example Site",
"alternateName" : "example",
"description" : "Welcome to this WebSite",
"headline" : "Welcome to Website",
"logo" : "https://example.com/public/images/logo.png",
"url" : "https://example.com/"
}
</script>
编辑:我也尝试过:
<link href="/public/json-ld.json" rel="alternate" type="application/ld+" />
谷歌蜘蛛似乎错过了它,测试工具也是如此,除非我直接指向文件。我正在努力解决CSP中不安全的内联问题。和,这将在Chrome中工作,但不希望在其他浏览器上触发控制台错误。另外,我很喜欢Schema.org数据从页面结构中抽象出来的想法。将JSON-LD添加到Google网站管理员工具的站点地图会有帮助吗
抱歉,JSON lD完全没有问题,并一直以电子邮件文档(这将是一个站点)或旧文档结尾。没错,它不能外部化,也不支持内联,但通过JavaScript文件将它注入DOM,您仍然可以实现您想要的目标 注意:我使用数组来保持整洁,因此我可以分割所有结构化数据元素并添加无限量的数据元素。我的网站上有一个更复杂的代码版本,实际上有一个外部服务器端渲染文件伪装成JavaScript文件 是的,谷歌搜索机器人确实明白这一点。注册可能需要几天时间,使用网站管理员工具强制重新爬网似乎不会强制刷新JSON-LD数据-似乎您只需等待
var structuredData = {
schema: {
corporation: {
'@context': 'http://schema.org',
'@type': 'Corporation',
'name': 'Acme',
'url': 'https://acme.com',
'contactPoint':
{
'@type': 'ContactPoint',
'telephone': '+1-1234-567-890',
'contactType': 'customer service',
'areaServed': 'US'
}
},
service: {
'@context': 'http://schema.org/',
'@type': 'Service',
'name': 'Code optimization',
'serviceOutput' : 'Externalized json',
'description': 'Inline json to externalized json'
},
},
init: function () {
var g = [];
var sd = structuredData;
g.push(sd.schema.corporation);
g.push(sd.schema.service);
//etc.
var o = document.createElement('script');
o.type = 'application/ld+json';
o.innerHTML = JSON.stringify(g);
var d = document; (d.head || d.body).appendChild(o);
}
}
structuredData.init();
可能是重复的,我试过了,但仍然没有被捡起来。我最好的猜测是,外部文件中还不支持网站的JSON-LD。
var structuredData = {
schema: {
corporation: {
'@context': 'http://schema.org',
'@type': 'Corporation',
'name': 'Acme',
'url': 'https://acme.com',
'contactPoint':
{
'@type': 'ContactPoint',
'telephone': '+1-1234-567-890',
'contactType': 'customer service',
'areaServed': 'US'
}
},
service: {
'@context': 'http://schema.org/',
'@type': 'Service',
'name': 'Code optimization',
'serviceOutput' : 'Externalized json',
'description': 'Inline json to externalized json'
},
},
init: function () {
var g = [];
var sd = structuredData;
g.push(sd.schema.corporation);
g.push(sd.schema.service);
//etc.
var o = document.createElement('script');
o.type = 'application/ld+json';
o.innerHTML = JSON.stringify(g);
var d = document; (d.head || d.body).appendChild(o);
}
}
structuredData.init();