Skip to Content
FeaturesModulesOG ImagesBranding & Icons

OG Image Branding & Icons

get_branded_og_url is a higher-level helper that renders an OG image with a logo, site name, and/or a built-in Material icon overlaid at the position defined by the active layout preset.

Basic usage

from django_cfg.modules.django_ogimage import get_branded_og_url, DARK_BLUE params = DARK_BLUE.to_params(title="My Page", description="Subtitle") # Site name only url = get_branded_og_url(params, site_name="Acme Corp") # → /media/ogimage/ab/cd/abcdef....png

Parameters

def get_branded_og_url( params: OGImageParams, *, logo_url: str = "", # path or URL to PNG/SVG logo file icon: str = "", # built-in icon name (e.g. "dashboard") site_name: str = "", # text label next to logo layout: OGLayoutPreset = DEFAULT, request=None, # Django request — returns absolute URL if provided ) -> str: ...

Priority: logo_url takes precedence over icon. If both are empty, only the site_name text is rendered.

With a built-in icon

50 top Material Design icons are bundled as SVG files and automatically rasterized at render time:

from django_cfg.modules.django_ogimage import get_branded_og_url, DARK_BLUE, list_icons # See all available icon names icons = list_icons() # ["account_circle", "add", "arrow_back", "dashboard", "email", "home", "settings", ...] url = get_branded_og_url( DARK_BLUE.to_params(title="Dashboard"), icon="dashboard", site_name="Acme", )

Passing an unknown icon name raises ValueError:

get_branded_og_url(params, icon="nonexistent") # ValueError: Icon 'nonexistent' not found. Available: account_circle, add, ...

Pass a file path to any PNG or SVG file. SVG files are automatically rasterized via skia.SVGDOM:

url = get_branded_og_url( params, logo_url="/srv/media/logo.svg", site_name="Acme Corp", )

With a layout

from django_cfg.modules.django_ogimage import HERO, ARTICLE # Brand in top-left (HERO layout) url = get_branded_og_url(params, icon="dashboard", site_name="Acme", layout=HERO) # Brand in top-left, no accent bar (ARTICLE layout) url = get_branded_og_url(params, site_name="Acme Docs", layout=ARTICLE)

See Layouts for all available layout presets.

Absolute URL

url = get_branded_og_url(params, site_name="Acme", request=request) # → https://example.com/media/ogimage/ab/cd/abcdef....png

Caching

get_branded_og_url has its own combined cache key:

SHA256[:40](compute_cache_key(params) + json(logo_url, site_name, layout.name))

The second call with identical inputs skips rendering entirely and returns the cached file URL immediately.

Built-in icon registry

from django_cfg.modules.django_ogimage import list_icons, get_icon_path # All available icon names (sorted) icons = list_icons() # Path to a specific SVG file path = get_icon_path("home") # → Path(.../core/assets/icons/home.svg) path = get_icon_path("missing") # → ValueError

Available icons

10 icons curated for SaaS product OG images:

IconUse case
dashboardOverview / home page
analyticsMetrics, reports, insights
peopleTeam, users, collaboration
paymentsBilling, subscriptions, pricing
securityAccess control, compliance
rocket_launchOnboarding, launch, getting started
support_agentSupport, help center
cloudInfrastructure, hosting, cloud services
verifiedTrust, verification, quality
auto_awesomeAI features, automation, highlights

To refresh the set, run update_icons.py — it downloads the curated set from Google Fonts and bakes them into the package:

python src/django_cfg/modules/django_ogimage/scripts/update_icons.py
  • Layouts — layout presets that control brand position
  • Presets — color scheme presets
  • Overview — quick start
Last updated on