Go to main content

Open graph meta tags enhanced by Kentico macros

Social media networks need more information about your content than just an url to be able to display it in their feeds. For such a purpose we put open graph meta tags in the head section of our websites. 

Open graph meta tags enhanced by Kentico macros

In Kentico we can use the Head HTML code web part to put a content into the head section of our website. In the content of this web part we can put the following code to generate open graph meta tags automatically. But read about theory first to be able to use the following code snippet properly in context of your website.


<meta property="og:title" content="{% CurrentDocument.DocumentName #%}" />
<meta property="og:type" content="article" />
<meta property="og:url" content="{% CurrentDocument.AbsoluteURL #%}" />
<meta property="og:description" content="{% StripTags(CurrentDocument.DocumentPageDescrition) #%}" />
<meta property="og:image" content="{%CurrentSite.SiteDomainName.GetAbsoluteUrl() + "/getattachment/" + CurrentDocument.MenuItemTeaserImage + CurrentDocument.NodeAliasPath #%}" />


Further reading

all posts