我只在客户端使用流星,并一直试图优化开放图元标记。我已经使用kadira:dochead
和在路由器把下面的代码:Facebook OG标签在流星不工作
Router.route('/', function() {
setupOg();
if (isMobile()) {
this.render('landing_mobile');
$('body').css("overflow", "visible");
}
else {
this.render('landing');
$('body').css("overflow", "hidden");
}
});
function setupOg() {
var title = { property: "og:title", content: "Blah" };
var type = { property: "og:type", content: "website" };
var url = { property: "og:url", content: "https://blah.io" };
var image = { property: "og:image", content: "http://i63.tinypic.com/2howf4k.png" };
var siteName = { property: "og:site_name", content: "Blah" };
var description = { property: "blah blah blah." };
DocHead.addMeta(title);
DocHead.addMeta(type);
DocHead.addMeta(url);
DocHead.addMeta(image);
DocHead.addMeta(siteName);
DocHead.addMeta(description);
}
在浏览器中,当检查头的内容,所述内容是那里作为<meta property="og:title" content="Blah" dochead="1">
等对上述各特性。
但是,当我看到Facebook Sharing Debugger时,似乎没有发现任何这些优化,并且当我尝试在LinkedIn上分享时,也是如此。为什么是这样?
注意,我main.html
看起来是这样的:
<head>
<link rel="icon" sizes="16x16 32x32" href="/favicon.ico">
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Blah</title>
</head>
您应该使用预渲染lib或服务如已经提到的,一些其他链接:[增强spiderable包(https://github.com/VeliovGroup/jazeee-meteor-spiderable),[有ES6支持预渲染](https://ostr.io/info/prerendering) –