Getting Facebook meta tags to work with Heroku on a custom domain
I have a domain that points to a Heroku dyno running a Node.js web app. To facilitate sharing, I added Facebook Open Graph meta tags to the html headers. However, I could not get Facebook to “see” the tags in the Facebook Sharing Debugger using my custom domain, even trying multiple variations of meta tags to be more attractive to Facebook’s crawler without luck. I could not find a solution from search engines or in the typical troubleshooting forums like stackoverflow.
Finally, I tested the Debugger using the direct heroku url (like
http://your-custom-app-name.herokuapp.com) , and all the meta tags immediately were recognized. Then I entered my custom domain, and voilà, all the meta tags were picked up there as well. I tested adding the link to a post in facebook, and the proper preview displayed.
I assume the redirect from a custom domain to a heroku url interrupts Facebook’s crawler, but once Facebook caches the meta tags at the target domain, it can properly display them using the custom domain. I am interested to hear a more technical explanation to this in the comments.
Hope this tip helps!