Search code examples
ajaxfacebookfacebook-liketitle

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


Solution

  • 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