Server-rendered web framework
Add automatic MyOG.social images to Rails layouts and views with ERB helpers, request URLs, and content_for overrides.
Rails layouts render shared head markup around controller views, which makes them the natural place for default Open Graph tags.
Use request.original_url or a canonical URL value from the controller, encode it, and pass it to MyOG so each public route gets its own generated image.
For pages that need custom handling, content_for lets an individual view provide page-specific head tags while the layout keeps a fallback.
MyOG detects page content and branding automatically. The layout only controls image composition.
Use this in app/views/layouts/application.html.erb or a shared head partial.
<% page_url = request.original_url %>
<% myog_image_url = "https://api.myog.social/og?url=#{ERB::Util.url_encode(page_url)}&template=screenshot-right" %>
<meta property="og:image" content="<%= myog_image_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="<%= myog_image_url %>" />If a controller sets a canonical URL, use that value instead of request.original_url.
Rails apps often have SEO helpers, meta-tags gems, or layout partials that already emit og:image. Replace that image source with MyOG or gate the fallback so only one preferred og:image appears.
For posts, products, docs, and marketing pages, request.original_url works when the route URL is already canonical. If you canonicalize slugs or strip query parameters, build and pass that canonical URL instead.
Start with the MyOG Open Graph Checker, then refresh social platform caches if needed.
Sign up for free and add generated social images to Rails pages.
Already have an account?
cdf733b534ea2f2ed964d150330b323c44837e4f