How to customize pagetitle in typoscript

Sometimes it's usefull to customize the page title. With this snippet you can change the page title or add some special string.

config.noPageTitle = 2
page.headerData.5 = TEXT
page.headerData.5.field = subtitle // title
page.headerData.5.wrap = <title> &nbsp; |</title> 

Here is another sample that reads the page title wich is defined under "Template".

wrap=This is the title:|
# id of the template record
tables = sys_template
conf.sys_template >
conf.sys_template = TEXT

This snippet was submited by Dominic Pfluger.

You can also learn quite a lot from studying the short code snippet that actually generates the page title. The function that generates the page title is printTitle located in class.t3lib_tstemplate.php. It is invoked from renderContentWithHeader located in class.tslib_pagegen.php.

// Title
$titleTagContent = $GLOBALS['TSFE']->tmpl->printTitle($GLOBALS['TSFE']->altPageTitle ? $GLOBALS['TSFE']->altPageTitle : $GLOBALS['TSFE']->page['title'], $GLOBALS['TSFE']->config['config']['noPageTitle'], $GLOBALS['TSFE']->config['config']['pageTitleFirst']);

if ($GLOBALS['TSFE']->config['config']['titleTagFunction']) {
   $titleTagContent = $GLOBALS['TSFE']->cObj->callUserFunction($GLOBALS['TSFE']->config['config']['titleTagFunction'], array (), $titleTagContent);

if (strlen($titleTagContent) && intval($GLOBALS['TSFE']->config['config']['noPageTitle']) !== 2) {

  • The $GLOBALS['TSFE']->altPageTitle is simply a placeholder in case some extension desire to modify the page title. If it is set it will be used instead of the actual page title.
  • The $GLOBALS['TSFE']->config['config']['noPageTitle'] is a value of config.noPageTitle which is decribed in TSREF as follows:

    If you only want to have the sitename (from the template record) in your <title> tag, set this to 1. If the value is 2 then the <title> tag is not printed at all.

    Please take note that this tag is required for XHTML compliant output, so you should only disable this tag if you generate it manually already.

  • The $GLOBALS['TSFE']->config['config']['pageTitleFirst'] is a value of config.pageTitleFirst which is also described in TSREF as follows:

    If set (and the page title is printed) then the page-title will be printed BEFORE the template title.
  • The config.titleTagFunction enables you to modify the default title tag with an external PHP function.
  • Finally if config.noPageTitle does not equal 2 the page title is set.


The function printTitle is an interesting study in itself:

function printTitle($title,$no_title=0,$titleFirst=0)    {
    $st = trim($this->setup['sitetitle']) ? $this->setup['sitetitle']:'';
    $title = $no_title ? '' : $title;
    if ($titleFirst)    {
    if ($title && $st)    {
        return $st.': '.$title;
    } else {
        return $st.$title;

Since all the parameters that this function receives are described above you should be able to easily discern what exactly happens here. These two code snippets are sufficient for you to have a full grasp of title tag generation in TYPO3. There are some extension that will override the default title tag such as tt_news, but that is a whole new issue in itself. Perhaps I will amend this article sometimes and explain how and why tt_news does it.

Your thoughts

No comments

Add comment

* - required field