Adding OpenGraph/meta data to routes? Agreed upon method?


#1

Hi everyone,

I’m writing a blog and I would like my links to appear with images/descriptions when posted to FB and other social media sites. I familiarized myself with https://github.com/meteorhacks/meteor-ssr, https://github.com/kadirahq/flow-router, and https://github.com/meteorhacks/picker by @arunoda.

I understand we can use SSRendering and SSRouting to serve static versions of our page. When a regular user hits my page, the javascript app is served. I am assuming this will not suffice for facebook bots trying to read OG data because I would only be able to modify via javascript. So we need to serve facebook a different URL.

I was thinking of specifying the “_escaped_fragment_=” version of the URL (a server side route, which serves rendered HTML) in my tags instead of the regular URL. This way, when facebook hits my site to get OG data, it will see the meta data corresponding to the route and params in question. If the user wants to share my link to facebook, I’ll modify the url to be the current URL plus the “_escaped_fragment_=”, so they share the static link.

Is this the preferred way to do this, or is there a better way? If I did it this way, then the link shared to facebook would direct the users to the static link. Is there some agreed upon solution for handling dynamic data? Please no iron-router solutions, thanks!


#2

OK New solution, which might be better - I wasn’t quite sure if Picker did this before… :

Use Picker’s next() functionality as follows :

//in picker handler
if (userAgentIsBot(req)){
  //use SSR.render(), serve static page
} else {
  //let client handle the route.
  next()
}

Some thing which might go wrong: If there is not a fool-proof way to determine if the user is a FB/TW/GOOG bot, then this will not be as sturdy as manually specifying an \escaped_fragment_route and then for sure serving the static html there.

Also, I think there will be a latency introduced on all client side routes, due to an extra round trip loop to the server for all req.

Thoughts? Does anyone know if the FB bots follow the _escaped_fragment_ convention? Ugh, that there isn’t a unified protocol.


#3

This is hilarious! Apparently this guy went through the exact same thing that I’m going through …

… and made the same set of conclusions. I think I will go with the solution mentioned in the SO post, or by using the #! urls.