简体   繁体   中英

Facebook Open Graph Single Page Apps

I have built a single page application using backbone js. I have separate backbone url "routes" for various application states and dynamic content (eg 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?

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

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