File imports

To structure and reuse single TypoScript snippets and not stuffing everything into one file or record, the syntax allows loading TypoScript content from sub files.

The two keywords are @import and the old school <INCLUDE_TYPOSCRIPT:. They are a syntax construct and thus available in both frontend Typoscript and backend TSconfig.

Both @import and <INCLUDE_TYPOSCRIPT: allow including additional files using wildcards. @import is a bit more restricted, though. The TYPO3 Core strives to get rid of <INCLUDE_TYPOSCRIPT: mid-term, and @import has been tuned with TYPO3 v12 to show good performance metrics. Integrators should prefer @import over <INCLUDE_TYPOSCRIPT: since it is best practice and more future proof.

The TypoScript parser allows to place @import and <INCLUDE_TYPOSCRIPT: within condition bodies, which obsoletes the condition keyword of <INCLUDE_TYPOSCRIPT: and allows conditional imports with @import.

Neither @import nor <INCLUDE_TYPOSCRIPT: are allowed to be placed within code blocks.

Changed in version 12.2

@import and <INCLUDE_TYPOSCRIPT: basically break any curly braces level, resetting current scope to top level. While inclusion of files has never been documented to be valid within braces assignments, it still worked until TYPO3 v11. This is now disallowed and must not be used anymore. For example, a construct like this is invalid:

page = PAGE
page {
  # This import won't work!
  @import 'EXT:my_extension/Configuration/TypoScript/bar.typoscript'
  20 = TEXT
  20.value = bar


This keyword allows including files inspired by a syntax similar to SASS. It is restricted, but still allows wildcards on file level. Single files must end with .typoscript if included in frontend Typoscript. In backend TSconfig, single files should end with .tsconfig, but may end with .typoscript as well (for now).

The include logic is a bit more restrictive with TYPO3 v12, previous versions have been slightly more relaxed in this regard. See this changelog for more details.

The following rules apply:

  • Multiple files are imported in alphabetical order. If a special loading order is desired it is common to prefix the filenames with numbers that increase for files that shall be loaded later.
  • Recursion is allowed: Imported files can have @import statements.
  • The @import statement does not take a condition clause as the old <INCLUDE_TYPOSCRIPT condition=""> statement did. That kind of condition should be considered a conceptual mistake. It should not be used.
  • Changed in version 12.0

    It is allowed to put @import within a condition. This example imports the additional file only if a frontend user is logged in:

        @import './userIsLoggedIn.typoscript'
  • Both the old syntax <INCLUDE_TYPOSCRIPT> and the new one @import can be used at the same time.
  • Directory imports are not recursive, meaning that a directory import does not automatically travel down its subdirectories.
  • Quoting the filename is necessary with the new syntax. Either double quotes (") or single quotes (') can be used.
  • Wildcards * are only allowed on file level, not on directory level. Only a single wildcard character is allowed.
  • Includes relative to the current file location are allowed using ./ as prefix.
  • Includes must start with EXT: if not relative. Loading files outside of extensions is not possible.
  • Directory traversal using ../ is not allowed.

Some examples:

# Import a single file
@import 'EXT:my_extension/Configuration/TypoScript/randomfile.typoscript'

# Import multiple files in a single directory, sorted by file name
@import 'EXT:my_extension/Configuration/TypoScript/*.typoscript'

# It's possible to omit the file ending. For frontend TypoScript, ".typoscript" is
# appended automatically, backend TSconfig allows both ".typoscript" and ".tsconfig"
@import 'EXT:my_extension/Configuration/TypoScript/'

# Import files starting with "foo", ending with ".typoscript" (frontend)
@import 'EXT:my_extension/Configuration/TypoScript/foo*'

# Import files ending with ".setup.typoscript"
@import 'EXT:my_extension/Configuration/TypoScript/*.setup.typoscript'

# Import "bar.typoscript" relative to current file
@import './bar.typoscript'

# Import all ".setup.typoscript" files in sub directory relative to current file
@import './subDirectory/*.setup.typoscript'


This traditional include instruction works as well. It is more clumsy and permissive, does not follow best practices. It should be avoided as of TYPO3 v12 and is likely to be deprecated with TYPO3 v13. It looks like this:

<INCLUDE_TYPOSCRIPT: source="FILE:EXT:my_extension/Configuration/TypoScript/myMenu.typoscript">

More details:

  • Keyword "FILE":

    A reference to a single file relative to \TYPO3\CMS\Core\Core\Environment::getPublicPath().

    Paths relative to the including file can be used, if the inclusion is called from inside a file. These paths start with FILE:./. This allows simple, nested TypoScript templates that can be moved or copied without the need to adapt all includes.

    Files within extensions can be used using FILE:EXT:my_extension/path/to/file.typoscript. This should be the preferred usage, importing files not located within extensions is likely to be deprecated with TYPO3 v13, along with the file ending .txt.

  • Keyword "DIR":

    Can be used instead of FILE to include multiple files at once. It includes all files from a directory relative to \TYPO3\CMS\Core\Core\Environment::getPublicPath(), including subdirectories.

    Files are included in alphabetical. Also files are included first, then directories.

  • Keyword "extensions":

    Only valid in combination with "DIR" to restrict inclusion to files ending with specified string. Multiple extensions are separated by comma.

    This includes all those files from the directory fileadmin/templates/ and from subdirectories, which have the file extension .typoscript:

    <INCLUDE_TYPOSCRIPT: source="DIR:fileadmin/templates/" extensions="typoscript">
  • Keyword "condition":

    Conditions are the same as was presented in the condition chapter. The files or directories will be included only if the condition is met. Note this is obsolete with TYPO3 v12 since <INCLUDE_TYPOSCRIPT: can be placed inside a native condition as well, just like @import.

    <INCLUDE_TYPOSCRIPT: source="FILE:EXT:my_extension/Configuration/TypoScript/user.typoscript" condition="[frontend.user.isLoggedIn]">
    # Identical to:
      <INCLUDE_TYPOSCRIPT: source="FILE:EXT:my_extension/Configuration/TypoScript/user.typoscript">
    # And identical to:
      @import 'EXT:my_extension/Configuration/TypoScript/user.typoscript'