Developer forum

Forum » CMS - Standard features » Facebook OpenGraph

Facebook OpenGraph

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

I have to define facebook og properties for a project.

I have used the logic for defining the properties in MetaTags object:

Pageview.Meta.AddTag("og:title", Model.Title);  
 

Which renders this result:

<meta name="og:title" content="Aparat de spalat cu presiune -total - 130 bar - 1400w">

However, when analyzing the implementation on Facebook I get this message:

The following meta tags are specified using 'name' instead of 'property' and will be ignored unless specified using the 'property' key: og:type, og:url, og:image, og:site_name, og:title

Is there any way I can change the output of the tags?

Thank you,
Adrian


Replies

 
Morten Bengtson Dynamicweb Employee
Morten Bengtson
Reply
This post has been marked as an answer

Hi Adrian,

In order to override the default format you can provide a custom meta tag where you have full control over the markup. The name of the tag needs to start with "custom"...

Pageview.Meta.AddTag("customOpenGraphTitle", $"<meta property=\"og:title\" content=\"{Model.Title}\" />");

Another option is to implement this using snippets...

@SnippetStart("OpenGraph")
<meta property="og:title" content="@Model.Title" />
// Add more properties here
@SnippetEnd("OpenGraph")

// Place the following inside head element of master template
@RenderSnippet("OpenGraph")

Best regards,
Morten

Votes for this answer: 1
 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Morten,

That's Awesome !

Thank you very much.

Adrian

 

You must be logged in to post in the forum