Add site name to page title of each page - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

Add site name to page title of each page

  • Add site name to page title of each page
  • I am using Sitefinity 6.1 and want to simply add the sitename of my website to the page title of each page.

    eg. <title>Page name  - Sitename</title>

    Is there a way to add this inside the master page? I am quite new to Sitefinity and have limited backend experience so any help would be brilliant.

  • Hi Brian,

    I guess something like this in the page_load of the master page should work:

    Page.Title = String.Concat(Page.Title, " - Sitename")
  • Sorry Arno, could you explain a bit more about the page_load. Should I see this somewhere in my master template? Thanks so much.
  • Yes Arno I have my custom site set up using a master template inside visual studio but there is no reference on this page to page_load that I can add your code. Can you give the full synthax as to how to achieve this?

  • Hi Brian,

    You can try if this works for you (VB.NET syntax):

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
         Page.Title = String.Concat(Page.Title, " - Sitename")
    End Sub
  • Thanks Guys, thats an easy solution. Don't know how I didn't think of just using javascript. Thought there should be a an option to do something so simple inside the sitefinity control panel.

    Thanks again
  • Hi Brian,

    I assume you have a master page in the Visual Studio project of your website. That's where the page load event can be accessed. You'd best ask a developer to do so.
  • Hi,

    In my opinion the easiest solution is to drop a javascript widget in your masterpage (screenshot) and write something like this:
    document.title = "My company"+document.title;

    Just do not place it in <head> tag - elsewhere should do the trick (screenshot).

    Vassil Vassilev
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  • Hi,

    well, the title field is an important piece of information for search engines, and a javascript-based solution will not be visible to the search engine crawlers i guess.

    The "Page_Load" solution in the master file would be better in that respect.

    In the top of your master page you could try something like this:

    <script language="C#" runat="server">
        void Page_Load(object sender, EventArgs e)
            Page.Title += " - Site name";

  • I added Sondre's solution to my master page's .cs file and it works! Didn't work in my master page file directly.