netgen/open-graph-bundle
Symfony bundle for adding Open Graph meta tags to your pages, so links shared on Facebook, Twitter, and other social networks display rich titles, descriptions, and images. Integrates with eZ Platform and Netgen templates.
netgen/open-graph-bundle is a very thin helper: it gives you a Twig extension (and a small PHP service) that collects property/content pairs and renders them as <meta property="og:..."> tags. That is essentially the entire feature set — there is no admin UI, no field type, no automatic extraction of Open Graph data from eZ/Ibexa content. Expect to spend more time deciding what to put in the tags than wiring the bundle.
Minimal steps:
composer require netgen/open-graph-bundleconfig/bundles.php:
Netgen\OpenGraphBundle\NetgenOpenGraphBundle::class => ['all' => true],
(On legacy eZ Platform, enable it in app/AppKernel.php / ezplatform.yml instead.)<head> in your pagelayout or detail template — the bundle exposes netgen_open_graph() in Twig; check the README for the exact argument shape, since the extension is a single method and is the whole public API.Where to look first: vendor/netgen/open-graph-bundle/README.md, then the Twig extension class under Templating/Twig/Extension/. Don't go hunting for config trees — there is very little to configure.
First real use case: an article detail template, populating og:title, og:description, og:image, og:type and og:url from eZ/Ibexa fields:
{% set og = netgen_open_graph() %}
{% do og.addTag('og:title', ez_field_value(content, 'title')) %}
{% do og.addTag('og:description', ez_field_value(content, 'intro')|striptags|slice(0, 200)) %}
{% do og.addTag('og:image', absolute_url(ez_image_alias(ez_field(content, 'image'), content.versionInfo, 'opengraph').uri)) %}
{% do og.addTag('og:url', absolute_url(ez_urlalias(content.contentInfo.mainLocationId))) %}
{% do og.addTag('og:type', 'article') %}
{{ og.render() }}
Split base tags from content tags. Put the site-wide fallbacks (og:site_name, og:type, default og:image = logo, og:locale) in the pagelayout, and let detail templates add/override per-content values. This avoids every template author re-inventing the same five tags — and avoids empty <head> sections on listing pages.
Write one macro and use it everywhere. A _og.html.twig macro taking (content, {type: 'article'}) with sensible fallbacks (title field → content name, intro → trimmed body, image field → site logo) is worth more than the bundle itself. The bundle doesn't know your content model; you do.
Always generate absolute URLs. og:image and og:url must be absolute — most scrapers silently drop relative paths. Use absolute_url() and a dedicated image alias (e.g. opengraph, 1200×630) rather than the original field value, so you control file size and aspect ratio.
Use the service in PHP when Twig isn't enough. For JSON endpoints, sitemap-ish generators, or tags that depend on runtime state, inject the OpenGraph service and add tags programmatically, then render into a string in the response template. This is also the cleaner path if you want to unit-test your tag-building logic.
Verify with real scrapers, not the markup. Facebook Sharing Debugger, LinkedIn Post Inspector, and curl -A facebookexternalhit against a cached page are the only tests that matter. Put a smoke assertion in a functional test (fetch the article page, assert og:title contains the field value) so a template refactor doesn't quietly kill your previews.
Cache-awareness: eZ/Ibexa view cache and HTTP cache store the rendered <head> along with the body. If you build tags from something request-dependent (user, query string, preview), either vary the cache or keep those tags out.
composer why-not netgen/open-graph-bundle on the symfony/* or ezsystems/* constraints — at which point the pragmatic move is to copy the extension class into your own src/ (it's a few dozen lines) rather than fork and maintain a repo.<head>, the extension returns markup that Twig auto-escapes (use |raw or the bundle's render method as documented), or addTag was given an empty value and the bundle skips it. Dump the collected tags before rendering to confirm.striptags, and let Twig's html_attr escaping handle the attribute — don't hand-concatenate the meta strings.<meta name="twitter:..."> yourself; consider whether a single macro producing both is cleaner.og:image (you may legitimately want several) and about og:type appearing after child properties. Emit base properties first, and de-duplicate when merging pagelayout fallbacks with template values — the bundle won't do it for you.templates/bundles/NetgenOpenGraphBundle/. Beyond that, don't expect plugin hooks — the bundle is too small to have any.og:image, hit the debugger's "scrape again" before concluding the bundle is broken.How can I help you explore Laravel packages today?