[SOLVED] OpenGraph and Custom Fields
Posted: Sat Mar 24, 2018 12:31 am
I want to make it so that when articles from my blog are linked on social media (essentially just Twitter and Facebook), the previews are "prettier". The way to do this seems to be through using OpenGraph Markup-based META tags in the HEAD of the page.
I'll explain how I imagine this working, and then I'd like some input on what I'm doing right or wrong:
The Plan
Have most of the <meta> tags already written into my index.tpl file -
The {$entry.properties.ep_PreviewImg} would be a custom field named PreviewImg, obviously. A few questions I about the above:
1. Do I have the right variable for the url?
2. Same question about the "preview" (og:description) - I would want it to be whatever text is shown before the "Read More" button that takes someone to the extended entry
3. Would putting this all in the index.tpl file be the wrong way about doing this? Can I put these tags (with the variables) in an HTML head nugget?
4. Am I calling the Custom Field properly in the above example?
Thanks ahead of time for any input you all might have!
I'll explain how I imagine this working, and then I'd like some input on what I'm doing right or wrong:
The Plan
Have most of the <meta> tags already written into my index.tpl file -
Code: Select all
<meta property="og:url" content="{$entry.link}" />
<meta property="og:type" content="article" />
<meta property="og:title" content="{$entry.title}" />
<meta property="og:description" content="{$entry.body}" />
<meta property="og:image" content="{$entry.properties.ep_PreviewImg}" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:site" content="@(twitter handle)" />
1. Do I have the right variable for the url?
2. Same question about the "preview" (og:description) - I would want it to be whatever text is shown before the "Read More" button that takes someone to the extended entry
3. Would putting this all in the index.tpl file be the wrong way about doing this? Can I put these tags (with the variables) in an HTML head nugget?
4. Am I calling the Custom Field properly in the above example?
Thanks ahead of time for any input you all might have!