Share pushState generated link with social networks

时间:2015-07-31 20:52:09

标签: jquery ajax

before implementing history.pushState my site I wonder if there is any way to change or to include data generated URLs as targets for social networks such as fb, these metatags are essential for sharing content:

<meta property="og:title" content="My website"/>
<meta property="og:image" content="http://www.example.com/facebook/road.jpg"/>
<meta property="og:site_name" content="Website"/>
<meta property="og:type" content="website" />
<meta property="og:url" content="http://www.example.com/" />

My website load content via AJAX and do not really know what would be a viable solution for sharing ajax generated content in social networks.

In addition I have plugins facebook comments and likes on my website without a URL do not work, always count the likes of index.php

Another solution I think is to make a copy of each content loaded by Ajax in new HTML pages and are these that are used to share content, but do not know if this will be good. Is it bad for SEO do this? ¿Penalize me for duplicate content?You could generate a sitemap?

Can I help you could decide?

1 个答案:

答案 0 :(得分:0)

我正在努力,但到目前为止还没有使用过jQuery,只是纯粹的javascript。 我有我的pushstate和popstate工作,并为通过ajax加载的文本文件添加了一个隐藏的div。当用户刷新或使用网址共享时,页面加载时没有样式。 然后,他/她必须转到主页并从头开始,这是我还没有解决的一个问题。我在我的div上放置了内联样式,这个样式隐藏在我的styles.css文件中,但是当页面加载时没有样式时,屏幕上会显示指向我主页的链接。 可怕的我想,我想实现类似的东西,从网址获取状态并去那里,但尚未找到解决方案。

但与你的问题更相关,我遇到了这个

<a href="https://developers.google.com/webmasters/ajax-crawling/docs/specification">here in developers.google!</a>

如果www.example.com没有hashframents并且包含在头部,则抓取工具会将此网址转换为www.example.com?_escaped_fragment_=并从网络服务器获取www.example.com?_escaped_fragment_=。 / p>

这让我变瘦了我可以用_escaped_fragment_ =来完成,无需添加#或!到我的网址。 我不是专业开发人员,但已将其视为#的解决方案!基于网站,但非常古老的问题,如

<a href="http://stackoverflow.com/questions/2568760/is-it-possible-to-use-    javascript-to-change-the-meta-tags-of-the-page">this one,</a>

现在对许多想要从ajax网页/应用程序中给出正确信息的开发人员非常重要,og:title等。