Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook like or share with dynamic document title

I found this problem all over the net but no answer yet, so maybe here someone solved it ...? I built a page relying heavily on jquery.address. It's got one index page and the rest loads dynamically via Ajax following Google's /#!/ scheme for crawlable pages. Now I want to add Facebooks Like or share button but I can't get it to grab the actual page title or url.

Whatever I do, it always falls back to title and url of the index page. It tried:

  • (obviously) changing title an openGraph meta on load of the new parts.
  • "linking" the crawler page (?_escaped_fragmet_=xyx) but specifying the #! page in meta
  • "sharing" with a given title and url.

I never get anything but a link to the index page or a blank "share" to the right url with title and thumbnail ignored.

Has anyone got a similar setup working?

Thanks for any hints, thomas

like image 828
thomas Avatar asked Nov 30 '10 09:11

thomas


3 Answers

Facebook is actually using #! now and it works! If you build your site so that http://site.de/?_escaped_fragment=something is identical to http://site.de/#!/something all you have to do is "share" the #! url and it'll display the info from the escaped fragment page.
Use this URL to check: http://developers.facebook.com/tools/debug

But: A much cleaner solution to the problem can be found here: http://github.com/browserstate/history.js/wiki/Intelligent-State-Handling

like image 64
thomas Avatar answered Oct 18 '22 01:10

thomas


My guess would be that Facebook's crawler doesn't run Javascript and will always display whatever's actually in the page it gets from the server.

like image 38
Angus Avatar answered Oct 18 '22 02:10

Angus


Facebook share has a BRUTAL cache, last time I checked it was impossible to change the title / description data once it was scraped :(

like image 36
dain Avatar answered Oct 18 '22 00:10

dain