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!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
George Marzloff

George Marzloff

133 Followers

Physician in Spinal Cord Injury & Physical Medicine and Rehab @ Rocky Mountain Regional VAMC, Colorado. Interests: Rehab Engineering & software development