3
10 Comments

Is there a way to have dynamic og share image?

Hi guys,

I'm wondering if there is any way to generate a dynamic og image for each different user? So that when they share their own profile page, there will be an image that's based off their personal profile.

on July 10, 2020
  1. 3

    You can probably look at Bannerbear - it seems like they're designed to make dynamic social images!

    1. 1

      Thank you for your answer, @richardchu, generating the image shouldn't be an issue, but from what I know og images are cached and if there isn't a separate page for each user, would they just be sharing the same image using the last generated image?

      1. 1

        Yup, as Gabe mentioned in a different comment each user would need to have their own page/URL.

  2. 2

    Depending on your tech stack you might use something like Puppeteer. Here’s a library which might help: https://github.com/chrisvxd/puppeteer-social-image

    1. 1

      Hey @Gabe, thanks for sharing, I haven't seen this before, looks good, I'll definitely try using this. But from what I know og images are cached and if there isn't a separate page for each user, would they just be sharing the same image using the last generated image?

      1. 1

        Yeah there would need to be a different page for each user that has their own image in the OG tag.

  3. 1

    @richardchu, @Gabe, ah... in this case are sites with individual og images statically generated sites? I can't imagine a site with 100k users having 100k actual HTML pages being served. I always thought it was just 1 template page dynamically showing content. I would probably have to rethink how to set this thing up if I wanted such sharing options.

    1. 1

      ea, for dynamic og images for posts, I guess Indie Hackers use Server Side Rendering to achieve that? I didn't read this as one of the advantages of SSR vs SPA previously. Interesting!

    2. 1

      I will also mention that most websites don't have different og images for different user profiles. For example, Indie Hackers doesn't even do this, even though they have dynamic og images for posts. By using Facebook's Sharing Debugger, you can see that there's no og image specified for my own profile.

    3. 1

      Just like the template page can show dynamic content it can dynamically include the right OG image meta tag in the page header. This would need to be done server-side (not appended client-side after the page loads).

      1. 1

        This comment was deleted 6 years ago