public function generate()
    {
        if (!$this->configurationHandler->isTheme() || $this->theme->getName() != $this->configurationHandler->handledTheme()) {
            return;
        }

        $templates = array_keys($this->templates["template"]);
        $homepage = json_decode(file_get_contents($this->configurationHandler->pagesDir() . '/' .$this->configurationHandler->homepage() . '/page.json'), true);
        $homepageTemplate = $homepage["template"];
        if (!in_array($homepageTemplate, $templates)) {
            $homepageTemplate = $templates[0];
        }

        $themeDefinition = array(
            "home_template" => $homepageTemplate,
            "templates" => $templates,
        );

        $this->synchronizeThemeSlots();
        FilesystemTools::writeFile($this->themeDir . '/theme.json', json_encode($themeDefinition));
    }