Forum

Thread tagged as: Problem, Configuration, Runway

Missing option to add an "og:image" for editors

I'm looking to populate the "og:image" and other social meta info that the editor to can add in the "Page Details" tab. I'm using the same code from the template, but only the description appears in the code and can be seen in the Page Details tab.

Leigh C

Leigh C 0 points

  • 3 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Can you show us?

Leigh C

Leigh C 0 points

Sorry - I thought that was clear. Here's the code:

<!-- SEO Meta Tags -->
    <meta name="description" content="<perch:pages id="description" label="Description" type="textarea" size="xs" escape="true" help="SEO Tip: limit to 160 chacters max.  Watch the counter on the right as you type   →" count="chars" />" />
    <meta name="keywords" content="<perch:pages id="keywords" label="Keywords" type="textarea" size="xs" escape="true" help="SEO Tip: A few words to match parts of the title.  Dont go overboard here. Separate with commas." count="chars" />" />
    <meta name="robots" content="<perch:pages id="noindex" label="Do not index" type="checkbox" value="noindex" append="," divider-before="Search engine indexing" /><perch:pages id="nofollow" label="Do not follow links" type="checkbox" value="nofollow" append="," /><perch:pages id="nosnippet" label="Do not show a snippet" type="checkbox" value="nosnippet" append="," />" />
    <meta name="revisit-after" content="1 month">

<!-- Social OG tags here -->
     <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="Title for this document with no branding or site name" divider-before="Facebook Open Graph Tags" />" />

    <meta property="og:description" content="<perch:pages id="description" label="Description" type="textarea" size="xs" escape="true" help="SEO Tip: limit to 160 chacters max.  Watch the counter on the right as you type   →" count="chars" />" />

    <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> 

And the result is this...


<!-- SEO Meta Tags --> <meta name="description" content="This is the description here. Learn more." /> <meta name="keywords" content="One, Two, Three" /> <meta name="robots" content="" /> <meta name="revisit-after" content="1 month"> <!-- Social OG tags here --> <meta property="og:site_name" content="" /> <meta property="og:url" content="" /> <meta property="og:title" content="" /> <meta property="og:description" content="This is the description here. Learn more." /> <meta property="og:image" content="" />

I don't see the image option in the Page Details, but I do see the Description option. So what am I missing?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Which template is that you've added to? Is it used as the page attribute master template, or used within it?

Leigh C

Leigh C 0 points

It's a template based on the seo.html standard template. I've just called it "master-seo.html" and added the OG items I wanted in there.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok, where is that being used? Is it part of your page attribute template?

Leigh C

Leigh C 0 points

Yes, here's how it's called into the page:


<!DOCTYPE html> <html dir="ltr" lang="en-US"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" /> <?php perch_page_attributes(array( 'template' => 'master-seo.html' )); ?> <?php perch_get_css(); ?> <!-- Browser Shortcut Icons --> <link rel="shortcut icon" type="image/x-icon" href="https://site.com/images/favicon.ico" > <link rel="apple-touch-icon" type="image/png" href="https://site.com/images/favicon/apple-touch-icon.png"> <link rel="mask-icon" href="https://site.com/images/favicon/logo.svg" color="#000000">

...and so on.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok, I see how you're using it as a display template. What about the master template used for editing?

Leigh C

Leigh C 0 points

Maybe that's what I'm missing.... this is all I have for generating those meta tags.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok, you should add the field to your master template for page attributes.

Leigh C

Leigh C 0 points

Can you remind me where that is in the structure? I can’t seem to find it.

Drew McLellan

Drew McLellan 2638 points
Perch Support

perch/templates/pages/attributes/default.html