💎

OG Images for Ruby on Rails

OG images for Rails — add to your layouts with one helper

OGMagic integrates with Rails views and layouts. Generate dynamic OG images using a simple URL helper — no gems to install.

Quick Start

Add OGMagic to your Ruby on Rails project — no packages to install, no API keys to configure.

Static OG Image
<%# app/views/layouts/application.html.erb %>
<head>
  <% og_url = "https://ogmagic.dev/api/og?" + {
    template: "gradient-mesh",
    title: content_for?(:title) ? yield(:title) : "My App",
    domain: request.host
  }.to_query %>
  <meta property="og:image" content="<%= og_url %>" />
  <meta property="og:image:width" content="1200" />
  <meta property="og:image:height" content="630" />
  <meta name="twitter:card" content="summary_large_image" />
  <meta name="twitter:image" content="<%= og_url %>" />
</head>

Dynamic OG Images

Generate unique OG images per page using route data:

Dynamic per-page
<%# app/views/posts/show.html.erb %>
<% content_for :og_image do %>
  <% og_url = "https://ogmagic.dev/api/og?" + {
    template: "minimal-dark",
    title: @post.title,
    description: truncate(@post.excerpt, length: 100),
    domain: request.host
  }.to_query %>
  <meta property="og:image" content="<%= og_url %>" />
  <meta property="og:image:width" content="1200" />
  <meta property="og:image:height" content="630" />
<% end %>

# Or use a helper (app/helpers/meta_helper.rb)
module MetaHelper
  def ogmagic_url(title:, template: "gradient-mesh", **opts)
    params = { template:, title:, domain: request.host }.merge(opts)
    "https://ogmagic.dev/api/og?#{params.to_query}"
  end
end

💡 Works with ERB, Haml, and Slim templates. Use .to_query for clean URL encoding. Compatible with meta-tags gem if you prefer a DSL.

Why use OGMagic with Ruby on Rails?

No build step

Images are generated on-demand via URL. No build plugins, no CI/CD changes.

🎨

55+ templates

Professional designs out of the box. Customize with query parameters.

🔑

No API key needed

Free tier works instantly — just use the URL. No signup, no config.

📱

Every platform

Optimized 1200×630 images that look great on Twitter/X, Facebook, LinkedIn, Discord, and Slack.

Ready to add OG images to your Ruby on Rails app?

Start with 50 free API calls/month. No signup needed.

Also works with