<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/rails-8-how-to-auto-generate-social-media-preview-cards-atispnhpj" -->

---
title: Rails 8: How to Auto-Generate Social Media Preview Cards
description: A step-by-step guide to auto-generating OpenGraph social media preview images in Rails 8 without paying for third-party APIs. The approach uses a dedicated...
canonical: https://daily.dev/posts/rails-8-how-to-auto-generate-social-media-preview-cards-atispnhpj
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Rails 8: How to Auto-Generate Social Media Preview Cards | daily.dev
og:description: A step-by-step guide to auto-generating OpenGraph social media preview images in Rails 8 without paying for third-party APIs. The approach uses a dedicated...
og:url: https://daily.dev/posts/rails-8-how-to-auto-generate-social-media-preview-cards-atispnhpj
og:image: https://api.daily.dev/og/posts/ATispnhpJ.png
og:image:alt: Rails 8: How to Auto-Generate Social Media Preview Cards
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Rails 8: How to Auto-Generate Social Media Preview Cards

**[Ruby Flow](https://daily.dev/sources/rubyflow)** · 5 min read · 0 upvotes · 0 comments

## Summary

A step-by-step guide to auto-generating OpenGraph social media preview images in Rails 8 without paying for third-party APIs. The approach uses a dedicated 1200x630 HTML/Tailwind card view, the Ferrum gem to take headless Chrome screenshots of that view, Solid Queue to run generation as a background job after post creation, and ActiveStorage to persist the resulting PNG. Finally, og:image and twitter:card meta tags are added to the post layout to surface the image on social platforms.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://norvilis.com/rails-8-how-to-auto-generate-social-media-preview-cards>

## Similar posts on daily.dev

- [Open Graph Image Generation in Rails](https://daily.dev/posts/open-graph-image-generation-in-rails-5vecgi43k) · RUBYLAND · 0 upvotes · 0 comments
- [How I generate an Open Graph image for every post](https://daily.dev/posts/how-i-generate-an-open-graph-image-for-every-post-fouqece4o) · Flavio Copes · 1 upvotes · 0 comments
- [Active Storage Image Optimization: 1,916 Photos, One Box](https://daily.dev/posts/active-storage-image-optimization-1-916-photos-one-box-kxpavbe7v) · Ruby Flow · 0 upvotes · 0 comments
- [Self-updating screenshots](https://daily.dev/posts/self-updating-screenshots-6qhtiffea) · Hacker News · 4 upvotes · 1 comments
- [Why GitHub’s Default Social Cards Are a UX Anti-Pattern](https://daily.dev/posts/why-github-s-default-social-cards-are-a-ux-anti-pattern-txq5pbqqc) · ITNEXT · 0 upvotes · 0 comments

---

Tags: [#rails](https://daily.dev/tags/rails), [#tailwind-css](https://daily.dev/tags/tailwind-css)

[View this post on daily.dev](https://daily.dev/posts/rails-8-how-to-auto-generate-social-media-preview-cards-atispnhpj)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Rails 8: How to Auto-Generate Social Media Preview Cards","url":"https://daily.dev/posts/rails-8-how-to-auto-generate-social-media-preview-cards-atispnhpj","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/rails-8-how-to-auto-generate-social-media-preview-cards-atispnhpj"},"datePublished":"2026-04-27T05:31:55.015Z","dateModified":"2026-04-27T05:32:18.630Z","description":"A step-by-step guide to auto-generating OpenGraph social media preview images in Rails 8 without paying for third-party APIs. The approach uses a dedicated...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/5b02502d3127a75a9d6b5225122f2c69?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/5b02502d3127a75a9d6b5225122f2c69?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Ruby Flow","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Ruby Flow","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/a21aaa8bcbbf448193a016895c90a0e1","url":"https://daily.dev/sources/rubyflow"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/rails-8-how-to-auto-generate-social-media-preview-cards-atispnhpj","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"rails,tailwind-css","timeRequired":"PT5M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Ruby Flow","item":"https://daily.dev/sources/rubyflow"},{"@type":"ListItem","position":3,"name":"Rails 8: How to Auto-Generate Social Media Preview Cards"}]}
```

