[英]Replace title that can be tracked by social media with JavaScript
Ho do I replace document.title
so social media (eg VK) will be read it by link with a hash-bang? 我该如何替换document.title
以便社交媒体(例如VK)通过散列链接进行读取? Here is what I've tried to do in my $.ajax()
call: 这是我在$.ajax()
调用中尝试执行的操作:
success: (function(_this) {
return function(data) {
_this.articles[id] = data;
var desc = ((data.seo_description.length > 0) ? data.seo_description : data.description);
document.title = data.title;
$("meta[name='description']").attr("content", desc);
return _this.setArticleData(data, full);
};
They do change on my page dynamically, but with I patse my link to VK (eg example.com/media/#open-full-178
) I see title and meta from example.com/media/
. 它们确实在我的页面上动态更改,但是通过我粘贴到VK的链接(例如example.com/media/#open-full-178
),我可以从example.com/media/
看到标题和元数据。
You should learn about _escaped_fragment_ concept to achieve SEO for dynamic websites. 您应该了解_escaped_fragment_概念,以实现动态网站的SEO。
You can either use existing services like "prerender" or run your own phantomjs server to render javascript before serving the pages to search engines. 您可以使用现有的服务(例如“ prerender”),也可以运行自己的phantomjs服务器来呈现javascript,然后再将页面提供给搜索引擎。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.