Creating Themes
# Creating Themes in FearlessCMS FearlessCMS uses a simple but powerful theme system that allows you to create custom themes with HTML templates, CSS styling, and optional theme options. This guide will walk you through creating a complete theme from scratch. ## Table of Contents 1. [Theme Structure](#theme-structure) 2. [Required Files](#required-files) 3. [Template System](#template-system) 4. [Template Variables](#template-variables) 5. [Theme Options](#theme-options) 6. [Theme Thumbnails](#theme-thumbnails) 7. [CSS and Styling](#css-and-styling) 8. [Example: Creating a Simple Theme](#example-creating-a-simple-theme) 9. [Advanced Features](#advanced-features) 10. [Best Practices](#best-practices) ## Theme Structure A FearlessCMS theme consists of the following directory structure: ``` themes/ └── your-theme-name/ ├── templates/ │ ├── home.html # Page template │ ├── page.html # Page template │ ├── blog.html # Page template │ ├── 404.html # Page template │ ├── header.html.mod # Module file │ ├── footer.html.mod # Module file │ ├── head.html.mod # Module file │ └── sidebar.html.mod # Module file ├── assets/ │ ├── style.css │ ├── images/ │ └── js/ ├── config.json # Theme configuration ├── thumbnail.png # Theme preview image (optional) └── README.md # Documentation ``` ## Required Files ### 1. theme.json This is the main theme configuration file that defines your theme's metadata: ```json { "name": "Your Theme Name", "description": "A brief description of your theme", "version": "1.0.0", "author": "Your Name", "license": "MIT", "templates": { "home": "home.html", "page": "page.html", "blog": "blog.html", "404": "404.html" } } ``` ### 2. Templates You need at least these **page template** files in the `templates/` directory: - **page.html** - Individual page template (required) - **404.html** - Error page template (required) - **home.html** - Homepage template (optional) - **blog.html** - Blog listing template (optional) **Note**: Page templates use the `.html` extension and will appear as template options in the admin interface when creating or editing content. ### Page Templates vs Modules **Page Templates** (`.html` extension): - Used as full page layouts - Appear in admin template selection dropdown - Examples: `page.html`, `home.html`, `404.html`, `blog.html` **Module Files** (`.html.mod` extension): - Reusable components included in page templates - Do not appear in admin template selection - Examples: `header.html.mod`, `footer.html.mod`, `sidebar.html.mod` ## Template System FearlessCMS uses a simple template system with variable substitution and conditional logic. Templates are written in HTML with special syntax for dynamic content. ### Basic Template Syntax ```html{{siteName}}
{{title}}
{{/if}} {{#if children}}-
{{#each children}}
- {{title}} {{/each}}
{{module=sidebar.html}}
{{siteName}}
{{#if siteDescription}}
{{/if}}
{{#if themeOptions.logo}}
{{else}}