Search code examples
javascripthtmltwittermetatwitter-card

Dynamic Twitter Card Images


I have a Twitter share button on an application I'm building. I am using the Twitter card <meta> tags (documentation) to define the image that shows up on Twitter. The application is dynamic and allows you to share individual 'reports'. When you share an individual report, I have a query parameter ?report=1608 (see example).

The problem: I can only define one Twitter card for the entire site. I would love to dynamically change the card information (title, text, image) for each individual report that is shared.

Can this be done? Any ideas?

I was thinking about just updating the meta tags dynamically with JavaScript, but I don't think this would work as a solution.


Solution

  • No, this is not possible. Twitter's card crawler (Twitterbot) does not support executing Javascript in the page and requires that the meta tags are static. There's no way to do this dynamically.