Facebook Open Graph Single Page Apps

倾然丶 夕夏残阳落幕 提交于 2019-12-30 07:12:30

问题


I have built a single page application using backbone js. I have separate backbone url "routes" for various application states and dynamic content (e.g. books), but essentially Facebook will only ever see the index page.

The following SO question seems to provide an interesting approach to providing physical open graph URLs for dynamic content:

Multiple Facebook opengraph objects on the same page

How have other developers approached using open graph tags on dynamic pages, specifically in single page apps?


回答1:


You can have the server output dynamic content for this, but you still need a different url for each object since this is how facebook index those objects.

What you can do however, is use the querystring or fragment parts of the url to identify it. So, let's say you have a single page that you want to serve all the open graph objects: your-domain.com/og now you can add to it identifiers like this:

your-domain.com/og?type=3&id=432543643
your-domain.com/og#type=653&id=46t43g3
your-domain.com/og?type=25id=4tn4g43#anotherstring


来源:https://stackoverflow.com/questions/9725252/facebook-open-graph-single-page-apps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!