Using content representations to create OG images with home template

If you are wondering why you don’t get an ogImage on the start page, even though a home.png.php was created. Sourcecode by M. Steinberg

Here is the solution:

in the snippet you may have to change the query if you create an ogImage for each template.

<meta 
property="og:image" 
content="<?= e($page->template()->name() === 'home', $page->url() . '/'.$page->template()->name().'.png', $page->url() . '.png') ?>"
>