Forum

Thread tagged as: Problem, Blog

Facebook og image

Blog posts are sharing the wrong image on Facebook. They are randomly sharing images from elsewhere on the page, rather than the main blog post image. Here is my facebook.html

<meta property="og:site_name" content="<perch:pages id="sitename" type="hidden" />" />
<meta property="og:url" content="<perch:pages id="url" type="hidden" />" />
<meta property="og:title" content="<perch:pages id="og_title" label="Social title" type="text" escape="true" help="Blockchain Bugle" divider-before="Facebook Open Graph Tags" />" />
<meta property="og:description" content="<perch:pages id="og_description" label="Social description" type="textarea" size="s" escape="true" />" />
<perch:if exists="og_image">
<meta property="og:image" content="<perch:pages id="domain" type="hidden" /><perch:pages id="og_image" label="Image when shared" help="Should be at least 1200x630" type="image" width="1200" />" />
<perch:else />
<meta property="og:image" content="<perch:pages id="domain" type="hidden" /><perch:pages id="sharing_image" type="hidden" />" />
</perch:if>
<perch:if exists="og_type">
<meta property="og:type" content="<perch:pages id="og_type" label="Facebook type" type="select" options="article,book,profile,website,video,music" allowempty="true" />" />
</perch:if>
<perch:if exists="og_author">
<meta property="article:author" content="<perch:pages id="og_author" type="hidden" />" />
</perch:if>

...and here is the image part of post.html

<perch:if exists="image">
        <div>
            <img src="<perch:blog id="image" type="image" width="600" height="400" crop="true" label="Image" order="4" />" alt="<perch:blog id="postTitle" />" />
        </div>
    </perch:if>
Chris James

Chris James 0 points

  • 5 years ago
Rachel Andrew

Rachel Andrew 394 points
Perch Support

I would check what is being rendered in the page, then update your template so it is correct for what Facebook requires. If Facebook can't find an appropriate image it will just pick one.