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 Razor Sort Nodes Ascending or Descending

Umbraco Razor get Querystring

Create a .NET Contact Form that Gets the Last Url Visited in C# Can also be Used in Umbraco