Feb 23, 2012

Storing TypoScript in the file system

There was an interesting question in the TYPO3 mailing lists: “How do you store TypoScript?”. Here is how I do that.

I store TypoScript in the file system. There is a main file, which is included to the site TypoScript template using statement. This file contains statements to include other files.

Other files are created logically, per feature or group. For example, I usually have:
  • constants.txt – sets all constants
  • config.txt – includes all “config” settings (such as “config.absRefPrefix”, etc)
  • page.txt – creates PAGE object, including “page.headerData”
  • seo.txt – all SEO options (some “config” settings come here)
  • news.txt – includes the news plugin I use
  • home_page_objects.txt – all TypoScript object, specific for home page
  • ...and so on.
Plugin files (such as “news.txt”) also include files from corresponding extensions using . “Include static (from extensions)” is empty in the TypoScript database record. That allows granular control on all included files. TypoScript from the css_styled_content extension is included into “page.txt”.

I avoid having multiple places for the same set of options. For example, all news settings will be in “news.txt”. The only exceptions are:
  • seo.txt, which contains certain SEO options from “config”
  • “page.headerData”, which can appear in other files as necessary
However, “plugin.tt_news” will never appear outside of news.txt. Thus, if I need to choose news settings, I always know where they are. Also I can replace news plugins or remove it completely as necessary.

The buggest advantages of such approach are:
  • It is versionable. I use Git to store projects and store TypoScript in Git.
  • It is very clean and clear. I always know where the stuff is. Any new maintainer will be able to see it too immediately.
  • It allows to customise, replace or remove features very quickly.
If you have your own practices, please, share in comments.


  1. I use a sysfolder to store all Typoscript almost in the same structure you described. Wasn't there a file size limit for files with Typoscript?

  2. I usually use my own kind of base extension, that keeps all my (not only the project's) highly flexible typoscript snippets in subfolders and inserts options to the "Include static from ..." for each of those snippets. The snippets are built so, that i can control most of it by just setting some constants (i.e. make a 1 level navigation a 2 level one only by changing the constant).
    Everything that needs to be customized within the snippets (and cant be changed with constants) will be overwritten partially in my setup.txt which is being included by default as the last item in the include chain. This way I keep all my snippets modular and in one place (versioned as well). My setup.txt usually stays rather small.

  3. We use to name our files like setup_news.ts, tsconfig_xyz.ts or const_extensions.ts -- this way its obvious which kind of TS a specific file includes.
    General structure is similar to Busy Noggins TV framework.

    Afaik there is no size limit for external TS files.

  4. I also use external TypoScript Files. I think it is much easier to maintain your TypoScript code that way. Also I do not need to make database updates on the production version when I make changes in the integration version.

    I would be interested in an article about your GIT setup for your TYPO3 projects. I would greatly appreciate this.


  5. @Felix:
    I just read it was dropped since TYPO3 4.5

  6. Isn't there a problem with caching if you have your TS in an external file or did that recently change?

  7. I do not have any problems with caching :)

  8. First of all, Thank you Dmirty!

    With inspiring from your this post, We did try to setup structured and good way of storing TypoScript. Please take a look at here http://www.nitsan.in/blog/typo3/good-way-to-storing-and-integrating-typoscript-in-the-file-system.html

    In this way, we are saving lots development time. Please write us more suggestion/feedback.

    Thank you!

  9. @ndee: You may set
    > admPanel.override.tsdebug.forceTemplateParsing = 1
    in your backend user typoscript configuration. It makes TYPO3 re-parse
    the frontend TypoScript every time when you're logged in the backend.