Skip to content

Instantly share code, notes, and snippets.

@Silverstriper
Created February 2, 2012 07:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Silverstriper/1722112 to your computer and use it in GitHub Desktop.
Save Silverstriper/1722112 to your computer and use it in GitHub Desktop.
MetaTags RAZOR sample for Umbraco 4.7.1
@{
var node = @Model.AncestorOrSelf();
var canonicalUrl = String.Empty;
if (umbraco.library.RequestServerVariables("HTTP_HOST").ToLower().StartsWith("www")) {
canonicalUrl = string.Concat("http://", umbraco.library.RequestServerVariables("HTTP_HOST"), Model.Url);
} else {
canonicalUrl = string.Concat("http://www.", umbraco.library.RequestServerVariables("HTTP_HOST"), Model.Url);
}
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>@Model.Title : @node.siteName</title>
<meta name="description" content="@Model.metaDescription" />
<meta name="keywords" content="@Model.metaKeywords" />
<link rel="canonical" href="@canonicalUrl" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<link rel="shortcut icon" type="image/png" href="/favicon.png" />
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment