How to set the Sitefinity Page Title globally for MVC or Webforms

Here's a  trick to appending (or prefixing) your domain to your sitefinity site.

MVC


Webforms

Edit the code of your masterpage and paste this in

protected override void Render(HtmlTextWriter writer)
{
      
    if (!this.Page.Title.ToLower().Contains( "mysite"))
        this.Page.Title = this.Page.Title + " | mysite.com";
      
    base.Render(writer);
  
}


It wont work if it goes below the base.Render, so keep it above.

I've experimented and this is the safest place to do it as if you try in prerender, then visit a dynamic generated page with the PageTitleMode set to Append you'd get this

<pagename> <| mysite.com> <dynamicitemtitle>
not
<pagename> <dynamicitemtitle> <| mysite.com>


Did you like this post, did I help you out, are you feeling generous

  Buy me a beer

Comments