简体   繁体   中英

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? Here is what I've tried to do in my $.ajax() call:

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/ .

You should learn about _escaped_fragment_ concept to achieve SEO for dynamic websites.

You can either use existing services like "prerender" or run your own phantomjs server to render javascript before serving the pages to search engines.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM