Umbraco Razor Macro - Write out a Meta Data Title Automatically with page names

@inherits umbraco.MacroEngines.DynamicNodeContext

@if (@Model.pageTitle == "")  // where pageTitle is a field name in  your doctype
{
if (@Model.Id != 1062) // where 1062 is the id of the home page
{

@Html.Raw("My Web Site Name | ")


foreach (var page in Model.Ancestors().OrderBy("Level"))
{
if (@page.Id != 1062)
{
@page.Name @Html.Raw(" | ");
}
}
if (@Model.Id != 1062)
{
@Model.Name
}
}

}
else
{
@Model.pageTitle
}

Comments

Popular posts from this blog

Umbraco - Reset the Admin Password via SQL Server

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

Umbraco Macro for IFrame when Embedding Video, Vimeo Universal Player, or other types of IFrame on to a Page XSLT version and Razor Version