Back to News & Newsletter Support

Hessel
Hessel

Hello sir, how should I setup my og:image if I want the post image to show up on social media if I share the page for example on facebook? Now the homepage image appears and not the one from the blog post. Also, The {{title}} would be great.

gergo85
gergo85

Hi Hessel,

Good question :) This is my basic codes:

{% if post.image %}<meta property="og:image" content="{{ post.image|media }}">{% endif %}

<meta name="title" content="{% if post.meta_title %}{{ post.meta_title }}{% elseif post.title %}{{ post.title }}{% elseif this.page.meta_title %}{{ this.page.meta_title }}{% else %}{{ this.page.title }}{% endif %}"> <meta name="description" content="{% if post.meta_desc %}{{ post.meta_desc }}{% elseif post.summary %}{{ post.summary|nohtml }}{% elseif this.page.meta_description %}{{ this.page.meta_description }}{% else %}{{ this.page.description }}{% endif %}">

{% if this.page.baseFileName == 'blog' %}<link rel="canonical" href="{{ 'blog'|page }}">{% endif %}

Description: https://yoast.com/rel-canonical

Last updated

Hessel
Hessel

Thank you for the fast reply, your solution works great =D

1-3 of 3