{"id":340136,"date":"2021-05-14T13:34:49","date_gmt":"2021-05-14T20:34:49","guid":{"rendered":"https:\/\/css-tricks.com\/?p=340136"},"modified":"2021-09-10T06:36:06","modified_gmt":"2021-09-10T13:36:06","slug":"auto-generated-social-media-images","status":"publish","type":"post","link":"https:\/\/css-tricks.com\/auto-generated-social-media-images\/","title":{"rendered":"Auto-Generated Social Media Images"},"content":{"rendered":"\n

I’ve been thinking about social media images again<\/a>. You know, the images that (can) show up when you share a link in places like Twitter, Facebook, or iMessage. You’re essentially leaving money on the table without them, because they turn a regular post with a little ol’ link in it into a post with a big honkin’ attention grabbin’ image on it, with a massive clickable area. Of any image on a website, the social media image might be the #1 most viewed, most remembered, most network-requested image on the site.<\/p>\n\n\n\n\n\n\n\n

It’s essentially this bit of HTML that makes them happen:<\/p>\n\n\n\n

<meta property=\"og:image\" content=\"\/images\/social-media-image.jpg\" \/><\/code><\/pre>\n\n\n\n

But make sure to read up on it<\/a> as there are a bunch other other HTML tags to get right. <\/p>\n\n\n\n

I think I’m thinking about it again because GitHub seems to have new social media cards. These are new, right?<\/p>\n\n\n\n

\n
\n
\"\"
tweet<\/a><\/figcaption><\/figure>\n<\/div>\n\n\n\n
\n
\"\"
tweet<\/a><\/figcaption><\/figure>\n<\/div>\n<\/div>\n\n\n\n

Those GitHub social media images are clearly programmatically generated. Check out an example URL<\/a>. <\/p>\n\n\n

Automation<\/h3>\n\n\n

While I think you can get a lot of bang out of a totally hand-crafted bespoke-designed social media image, that’s not practical for sites with lots of pages: blogs, eCommerce… you know what I mean. The trick for sites like that is to automate their creation via templating somehow. I’ve mentioned other people’s takes on this in the past<\/a>, but let’s recap:<\/p>\n\n\n\n