Python web framework
Add automatic MyOG.social images to Django templates with request.build_absolute_uri, base templates, and per-view metadata.
Django projects commonly put social metadata in a base template, then override pieces from child templates or view context.
MyOG needs the absolute public page URL. Django's request.build_absolute_uri gives you that URL when request is available in the template context.
For canonicalized slugs, language prefixes, or query-stripped pages, pass a canonical_url value from the view and encode that instead.
MyOG detects page content and branding automatically. The layout only controls image composition.
Use this in your shared head template.
{% firstof canonical_url request.build_absolute_uri as page_url %}
<meta property="og:image" content="https://api.myog.social/og?url={{ page_url|urlencode }}&template=screenshot-right" />
<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="https://api.myog.social/og?url={{ page_url|urlencode }}&template=screenshot-right" />If your template engine cannot call request.build_absolute_uri here, compute page_url in the view and pass it in context.
If your base template, CMS plugin, or SEO package already outputs og:image, switch that source to MyOG or ensure child templates do not render a second competing image tag.
Detail views can pass canonical_url in context when the public URL should differ from the raw request URL. For ordinary public routes, request.build_absolute_uri is enough.
Start with the MyOG Open Graph Checker, then refresh social platform caches if needed.
Sign up for free and add generated OG images to Django pages.
Already have an account?
cdf733b534ea2f2ed964d150330b323c44837e4f