The title tag is one of the most important SEO factors for a website. Not only is it displayed in the browser tab, but it can also be used as the headline for search results on Google and other search engines.

In TYPO3, the title tag can be controlled very flexibly using TypoScript. For example, the page title, the name of the website or even individual values from page properties can be combined with one another.

In this article, I’ll show you how to customise the title tag in TYPO3 using TypoScript and how to change it depending on different conditions.

What is the title tag?

The title tag is included in the HTML document within the <title> element:

<title>My website | firma.de</title>

It should describe as precisely as possible what each page is about.

A typical structure might look like this, for example:

Page title | Website name

For a TYPO3 page, this might look like this, for example:

TYPO3 Development | Dev-Werk

By default, TYPO3 generates the title tag from the page properties. However, this behaviour can be customised using TypoScript.

Override the title tag using TypoScript

One simple way is to set the title tag via `config.pageTitle`.

For example:

config.pageTitle = TYPO3 Freelancer | Dev-Werk

This would result in the same title tag being displayed on every page.

However, for a website with multiple subpages, this is usually not a good idea. It is better to generate the title dynamically from the page properties.

Use page titles automatically

The page title can be retrieved using a TEXT object from ` page:title `.

config.pageTitle.cObject = TEXT
config.pageTitle.cObject {
field = title
}

This causes TYPO3 to use the title of the current page as the title tag.

For example, if the current page has the title:

TYPO3 Freelancer

this becomes:

<title>TYPO3 Freelancer</title>

This is already considerably more flexible than a static title tag.

Combine the page title and website name

In practice, it often makes sense to combine the page title with the name of the website.

For example:

TYPO3 Freelancer | Dev-Werk

This can be implemented using TypoScript as follows:

config.pageTitle.cObject = TEXT 
 config.pageTitle.cObject { 
  field = title 
  noTrimWrap = | | | Dev-Werk| 
}

The advantage of this option is that the title is automatically applied to every page.

Customise the title tag via page properties

For larger TYPO3 projects, it may be advisable not to generate the title tag solely from the page title.

TYPO3 provides dedicated SEO fields in the page properties for this purpose. These include, in particular, the field for the SEO title.

If a custom SEO title is available, this should be used in preference to the page title.

A simple example looks like this:

config.pageTitle.cObject = TEXT 
config.pageTitle.cObject { 
  field = seo_title 
  ifEmpty.cObject = TEXT 
  ifEmpty.cObject { 
    field = title 
  } 
}

In this case, the SEO title is used first.

If no SEO title is available, TYPO3 automatically falls back on the normal page title.

The principle works as follows:

 

Is there an SEO title?
        |
        +-- Yes --> Use SEO title
        |
        +-- No --> Use page title
New comment

0 comments