Created
October 27, 2017 08:05
-
-
Save ps-team/7cf6d713c52afb37542540a11500fc63 to your computer and use it in GitHub Desktop.
OpenGraph data output - Razor and metadata needed for displaying better Facebook and Twitter share images for each webpage. Just add to a base razor file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var OpenGraphImage = "https://www.cumbria.police.uk/SiteElements/Images/Facebook-logo.png"; | |
if(CurrentNode.ThumbnailUrl!="") { | |
OpenGraphImage = "https://www.cumbria.police.uk" + CurrentNode.ThumbnailUrl; | |
} | |
CurrentContext.Page.Head.Add("meta", new { property = "og:title", content = CurrentNode.Title }); | |
CurrentContext.Page.Head.Add("meta", new { property = "og:description", content = CurrentNode.Data.Description }); | |
CurrentContext.Page.Head.Add("meta", new { property = "og:image", content = OpenGraphImage }); | |
CurrentContext.Page.Head.Add("meta", new { property = "og:url", content = CurrentNode.FullPath }); | |
CurrentContext.Page.Head.Add("meta", new { property = "og:site_name", content = "Cumbria Constabulary" }); | |
CurrentContext.Page.Head.Add("meta", new { property = "og:type", content = "Article" }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment