Use Rails helpers and view partials to generate perfect OG images for every page in your app.
Get StartedClean Ruby DSL with helper methods that integrate seamlessly with your views.
Reusable partials that you can include in any layout or view template.
Works with both ERB and HAML templating engines out of the box.
# app/helpers/og_helper.rb
module OgHelper
def imago_og_url(title)
params = {
title: title,
template: 'modern',
api_key: ENV['IMAGO_API_KEY']
}
"https://imagoapi.com/api/og/generate?#{params.to_query}"
end
end
<!-- app/views/layouts/application.html.erb -->
<%= tag.meta property: 'og:image', content: imago_og_url(@post&.title || 'My Site') %>
<%= tag.meta name: 'twitter:image', content: imago_og_url(@post&.title || 'My Site') %>
Join thousands of developers using Imago API for dynamic social cards.
Start Free Trial