Using a Document Property as a Page Title

There are a few pages on this site located in a basic Web Part Page library that is cleverly named Webpart Pages. The default page title for these pages is ‘ListName – ItemName‘.

The code that does this is:

<asp:Content ContentPlaceHolderId="PlaceHolderPageTitle" runat="server">

    <SharePoint:ListProperty Property="Title" runat="server"/> –

    <SharePoint:ListItemProperty Property="BaseName" MaxLength=40 runat="server"/>

</asp:Content>

If I left this alone and added a page named MyPage to the library, the page title will be Webpart Pages – MyPage.

The user will see this title on their browser’s title bar, but more importantly, the title will show up in any search engine results.

If you need more control you can add a column to the document library and use its contents instead. Add a column named PageTitle to the library and set it to whatever you want to display.

Change the code to:

<asp:Content ContentPlaceHolderId="PlaceHolderPageTitle" runat="server">

    <SharePoint:ListItemProperty Property="PageTitle" MaxLength=40 runat="server"/>

</asp:Content>

As you can see, the SharePoint:ListItemProperty web control is a handy way to insert the value of any column in the current item wherever you need it in your page.