Umbraco 7 Metadata, Keywords, Description and Title

@{   
        var SEOTitle = "";
        var SEODescription = "";
        var SEOKeywords = "";
     }
     @if(CurrentPage.seoTitle != null && CurrentPage.seoTitle != "")
     {
        SEOTitle = CurrentPage.seoTitle;
     }
     else
     {
        SEOTitle = @CurrentPage.Url.Replace("/"," | ") + @CurrentPage._siteTitle;
        SEOTitle = SEOTitle.Substring(2, SEOTitle.Length-2);
     }    
     @if(CurrentPage.seoDescription != null && CurrentPage.seoDesctiption != "")
     {
        SEODescription = CurrentPage.seoDescription;
     }
     else
     {
        SEODescription = "This page is about" + @CurrentPage.Url.Replace("/"," ") + @CurrentPage._siteTitle;
     }
     @if(CurrentPage.seoKeywords != null && CurrentPage.seoKeywords != "")
     {
        SEOKeywords = CurrentPage.seoKeywords;
     }
     else
     {
        SEOKeywords = @CurrentPage.Url.Replace("/",",") + @CurrentPage._siteTitle;
        SEOKeywords = SEOKeywords.Substring(1, SEOKeywords.Length-1);
     }<title>@SEOTitle.Truncate(60)</title>

Comments

Popular posts from this blog

Umbraco 7 - C# Razor - Passing a parameter variable from a Template to a Partial View.

Umbraco Razor Sort Nodes Ascending or Descending

Umbraco - Reset the Admin Password via SQL Server