Home / Docs / themes
Developer Guide

Theme Development

Theme structure, theme.json manifest, template hierarchy, and rendering helpers.

Theme Development

Building a custom theme for Encrypt CMS is straightforward. Themes use native PHP templates with standard HTML, CSS, and JavaScript.


1. Directory Structure

Themes reside in themes/{theme-slug}/:

themes/
└── my-custom-theme/
    ├── theme.json            # Theme manifest (Mandatory)
    ├── screenshot.png        # Preview screenshot (800x600 recommended)
    ├── layouts/
    │   └── default.php       # Master HTML layout shell
    ├── home.php              # Homepage template
    ├── single.php            # Single article view
    ├── page.php              # Static page view
    ├── archive.php           # Category and tag archive view
    ├── 404.php               # Not found error template
    └── assets/
        ├── css/
        ├── js/
        └── images/

2. The theme.json Manifest

Every theme must include a theme.json file at its root:

{
  "name": "My Custom Theme",
  "slug": "my-custom-theme",
  "version": "1.0.0",
  "author": "Your Studio / Developer Name",
  "description": "High-performance editorial theme built for Encrypt CMS.",
  "screenshot": "screenshot.png",
  "template_files": [
    "layouts/default.php",
    "home.php",
    "single.php",
    "page.php",
    "404.php"
  ]
}

3. Core Template Helpers

Inside your theme templates, Encrypt CMS injects helper functions for URL generation and output escaping:

$e($string) — Secure HTML Escaping

<h1><?= $e($post['title']) ?></h1>

$url($path) — Site URL Generator

Generates canonical links matching your configured permalink structure:

<a href="<?= $url('/category/' . $category['slug']) ?>">
  <?= $e($category['name']) ?>
</a>

$asset($path) — Theme Asset URL Generator

Resolves asset paths relative to the active theme directory:

<link rel="stylesheet" href="<?= $asset('assets/css/style.css') ?>">
<script src="<?= $asset('assets/js/main.js') ?>" defer></script>