Theme Development & Chameleon TAL
Golem themes provide complete control over the layout, typography, aesthetic styling, and client-side behavior of generated documentation portals. Built on top of Chameleon Zope Page Templates (.pt) and standard TAL (Template Attribute Language), Golem couples powerful declarative templating with modern, parameterized CSS Custom Properties.
Theme Architecture & Layout Structure
A Golem theme is a self-contained directory containing layout templates and static assets. Golem locates and resolves themes using the following hierarchy:
- Explicit Custom Template: A template file designated in
templates_dir(e.g.templates/page.ptortemplates/skeleton.pt). - Project-Local Theme Folder: Located at
themes/<theme_name>/(e.g.themes/mytheme/skeleton.pt). - Packaged Plugin Theme: Discovered via Python package entry points in the
golem.themesgroup. - Built-in Default Theme: Shipped directly inside the
golempackage atsrc/golem/templates/default/skeleton.pt.
Standard Theme Directory Structure
themes/mytheme/
├── skeleton.pt # Main HTML5 Chameleon base template
└── static/ # Theme static assets (stylesheets, fonts, images, scripts)
├── css/
│ └── theme.css
├── js/
│ └── theme.js
└── images/
└── logo.svg
When Golem builds your documentation site, static assets in themes/<theme>/static/ are automatically synchronized into the output directory under dist/static/.
Template Context Variables
When rendering skeleton.pt, Golem passes a comprehensive set of template variables to Chameleon:
Variable | Type | Description |
|
| Title of the website configured in |
|
| Title of the current document extracted from the top-level AsciiDoc header ( |
|
| Configured site author name or organization (default: |
|
| Base URL of the website if configured (useful for |
|
| Active version string of the Golem engine (e.g. |
|
| Pre-rendered semantic HTML5 content generated from the AsciiDoc document body. |
|
| Hierarchical site map data structure containing |
|
| Pre-rendered semantic HTML5 navigation list ( |
|
| Rendered Table of Contents HTML unordered list generated from document headings ( |
|
| Path of the source document relative to the content root directory. |
|
| Previous document in sequential navigation order ( |
|
| Next document in sequential navigation order ( |
|
| Server-generated Pygments syntax highlighting CSS rules for light/dark mode. |
|
| Class name string extracted from |
|
| Class name string extracted from |
|
| List of custom stylesheet URLs or paths injected from configuration. |
|
| List of custom script URLs or paths injected from configuration. |
|
| Ordered breadcrumb trail from root to current page with |
|
| Web URL to edit the source document on GitHub/GitLab (injected by |
|
| Web URL to the repository homepage (injected by |
|
| Web URL to view the raw source document on GitHub/GitLab (injected by |
|
| Alphabetized document index mapping letters to terms and locations (injected by |
|
| Alphabetized glossary mapping letters to term definitions (injected by |
Chameleon TAL & METAL Syntax Reference
Chameleon templates use standard TAL (Template Attribute Language) and METAL (Macro Extension Template Attribute Language) XML attributes to inject dynamic data and construct modular layouts without breaking standard HTML syntax:
TAL Attributes
tal:content="variable": Replaces the element's text content with an HTML-escaped string value.tal:content="structure variable": Injects raw HTML markup without escaping (essential forbody_html,nav_html, andtoc_html).tal:replace="structure variable": Replaces the containing HTML tag itself with raw markup.tal:condition="variable": Renders the element conditionally only if the expression evaluates to truthy.tal:repeat="item collection": Loops through an iterable, repeating the element for each item.tal:attributes="attr expression": Dynamically sets HTML element attributes (e.g.tal:attributes="href item.url").${expression}: String interpolation syntax for inline variable substitution within text and attributes.
METAL Attributes
metal:define-macro="name": Defines a reusable layout macro that can be used or extended by other templates.metal:use-macro="expression": Replaces the element and its children with the body of the specified macro.metal:define-slot="slot_name": Designates an extension slot within a macro that child templates can override.metal:fill-slot="slot_name": Provides replacement markup for a designated macro slot when expanding a macro.
CSS Theme Custom Properties (--golem-*)
The default Golem theme ("Workbench" / Fired Clay aesthetic) is engineered entirely with parameterized CSS Custom Properties (--golem-*). Theme developers can completely re-skin Golem by overriding these variables in CSS without modifying the underlying HTML template.
Light Mode Palette Tokens
Token | Default Value | Role & Usage |
|
| Main document background color (warm parchment). |
|
| Elevated surfaces: header, sidebar navigation, footer, admonition backgrounds. |
|
| Background for inline code spans ( |
|
| High-contrast primary reading text and headings. |
|
| Secondary captions, metadata, table headers, and inactive links. |
|
| Brand accent color (terracotta / fired clay) used for active links, hover states, and key highlights. |
|
| Interactive hover and active focus state for primary brand elements. |
|
| Subtle borders for sidebar dividers, code blocks, tables, and section separators. |
|
| Standard hyperlink text color. |
|
| Hyperlink hover state color. |
|
| Visited hyperlink text color. |
|
| Accent border color for |
|
| Accent border color for |
|
| Accent border color for |
|
| Accent border color for |
|
| Accent border color for |
|
| Sub-perceptible SVG fractal noise texture overlay applied to the page body. |
Dark Mode Palette Overrides
Golem automatically supports dark mode via @media (prefers-color-scheme: dark). The dark theme uses charcoal and warm ember tones:
@media (prefers-color-scheme: dark) {
:root {
--golem-bg: #170f0b;
--golem-surface: #1e1410;
--golem-code-bg: #2a1e17;
--golem-text: #f0e4d8;
--golem-text-muted: #9a7a68;
--golem-primary: #d4692a;
--golem-primary-hover: #e07a3a;
--golem-border: #3d2a20;
--golem-link: #d4692a;
--golem-link-hover: #e07a3a;
--golem-link-visited: #8a4c32;
/* Admonitions */
--golem-note: #4a9a8a;
--golem-tip: #7aaa3a;
--golem-important: #d4692a;
--golem-warning: #d4a020;
--golem-caution: #c04040;
}
}
Typography Tokens
Golem utilizes four distinct font tokens corresponding to functional typography roles:
Token | Default Fallback Stack | Purpose |
|
| Document titles ( |
|
| Main narrative paragraphs, lists, blockquotes, and prose content. |
|
| Sidebar navigation items, table of contents links, metadata badges, table headers, and footers. |
|
| Code blocks ( |
Typographical Scale, Optical Sizing & Line-Height
Golem embraces modern CSS variable fonts with optical sizing controls and proportional leading:
- Optical Sizing (
opsz):CSSbody { font-optical-sizing: auto; font-variation-settings: "opsz" 12; line-height: 1.75; } #golem-content h1 { font-variation-settings: "opsz" 36; line-height: 1.2; letter-spacing: -0.01em; } #golem-content h2 { font-variation-settings: "opsz" 24; line-height: 1.3; } #golem-content h3 { font-variation-settings: "opsz" 18; line-height: 1.4; } pre, .listingblock pre { line-height: 1.55; } - Container Sizing & Readability:
The main reading column is constrained for optimal typographical line length (60–75 characters per line):
CSS#golem-content { flex: 1; padding: 2.5rem 3.5rem; max-width: 860px; } - Responsive Breakpoints:CSS
/* Collapses right Table of Contents on medium viewports */ @media (max-width: 1100px) { #golem-sidebar-right { display: none; } #golem-content { padding: 2rem 2.5rem; } } /* Stacks navigation and reading pane into single column on mobile */ @media (max-width: 800px) { #golem-wrapper { flex-direction: column; } #golem-sidebar-left { width: 100%; border-right: none; border-bottom: 1px solid var(--golem-border); } #golem-content { padding: 1.5rem 1.25rem; } }
Loading Custom Web Fonts & External Stylesheets
You can load custom web fonts and external stylesheets across your documentation site using the custom_css setting in your configuration file (golem.toml or pyproject.toml).
In golem.toml
[site]
title = "My Project Docs"
custom_css = [
"https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap",
"/static/css/custom.css",
]
custom_js = [
"/static/js/theme-switcher.js",
]
In pyproject.toml
[tool.golem.site]
title = "My Library Documentation"
custom_css = [
"https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;600&family=Outfit:wght@400;600;700&display=swap",
"/static/css/custom.css",
]
Applying Custom Fonts in static/css/custom.css
Once loaded, assign the font families to Golem's typography tokens:
:root {
--golem-font-display: 'Outfit', sans-serif;
--golem-font-body: 'Outfit', sans-serif;
--golem-font-ui: 'Outfit', sans-serif;
--golem-font-mono: 'Fira Code', monospace;
}
Code Listings & Multi-View Component Styling
Golem renders code blocks and multi-view derived listings as structured <figure> components with semantic headers, interactive tabs, language and test role badges, and clipboard copy controls.
DOM Structure & CSS Classes
Standard Listing Block
<figure class="listingblock" id="block-id">
<header class="listing-header">
<span class="listing-title">example.py</span>
<div class="listing-actions">
<span class="badge badge-test">test</span>
<span class="badge badge-lang">PYTHON</span>
<button type="button" class="listing-copy-btn" aria-label="Copy code to clipboard">
<svg class="icon-copy" ...></svg>
</button>
</div>
</header>
<div class="listing-content">
<pre class="highlight python"><code class="language-python">...</code></pre>
</div>
</figure>
Multi-View Derived Listing Block
<figure class="listingblock multi-view">
<header class="listing-header">
<span class="listing-title">Admonition Demo</span>
<div class="listing-tabs" role="tablist">
<button type="button" class="tab-btn active" data-tab="source" role="tab" aria-selected="true" tabindex="0">AsciiDoc</button>
<button type="button" class="tab-btn" data-tab="asg" role="tab" aria-selected="false" tabindex="-1">ASG</button>
<button type="button" class="tab-btn" data-tab="html" role="tab" aria-selected="false" tabindex="-1">HTML</button>
<button type="button" class="tab-btn" data-tab="preview" role="tab" aria-selected="false" tabindex="-1">Preview</button>
</div>
<div class="listing-actions">
<span class="badge badge-lang">ASCIIDOC</span>
<button type="button" class="listing-copy-btn" aria-label="Copy code to clipboard">...</button>
</div>
</header>
<div class="listing-panes">
<div class="tab-pane active" data-tab="source" role="tabpanel">
<pre class="highlight asciidoc"><code class="language-asciidoc">...</code></pre>
</div>
<div class="tab-pane" data-tab="asg" role="tabpanel" hidden="hidden">
<pre class="highlight json"><code class="language-json">...</code></pre>
</div>
<div class="tab-pane" data-tab="html" role="tabpanel" hidden="hidden">
<pre class="highlight html"><code class="language-html">...</code></pre>
</div>
<div class="tab-pane" data-tab="preview" role="tabpanel" hidden="hidden">
<div class="rendered-preview">...</div>
</div>
</div>
</figure>
Component Class Reference
Class Name | HTML Element | Role & Styling Purpose |
|
| Outer wrapper for code listings. Sets border, background ( |
|
| Modifier class applied when derived multi-view tabs ( |
|
| Flexbox header bar displaying title, tab controls, language badges, and actions against |
|
| Displays filename or block title with bold weight ( |
|
| Container ( |
|
| Interactive tab switcher ( |
|
| Right-aligned flex container housing role badges, language pill, and the copy button. |
|
| Base pill badge styling with uppercase typography ( |
|
| Pill badge displaying language identifier (e.g. |
|
| Semantic badge for |
|
| Semantic badge for |
|
| Semantic badge for |
|
| Clipboard copy trigger. Features hover states, focus rings, and a temporary |
|
| Wrapper for multi-view panes. |
|
| Individual view panel ( |
|
| Sandbox container for live rendered HTML in the |
Design Tokens for Listing Customization
Themes can customize code listings and multi-view blocks by overriding the following CSS custom properties:
:root {
/* Code block container & header */
--golem-code-bg: #ece7de;
--golem-surface: #f2ede8;
--golem-border: #cec8bf;
--golem-primary: #8b3a12;
/* Badges & Actions */
--golem-note: #2d6a5a;
--golem-tip: #6e7818;
--golem-warning: #b58a00;
/* Typography */
--golem-font-ui: 'Source Sans 3', sans-serif;
--golem-font-mono: 'Source Code Pro', monospace;
}
Overriding skeleton.pt in a Custom Theme
To create a fully customized theme or override Golem's default page structure:
- Create a theme directory:
themes/mytheme/. - Place a
skeleton.pttemplate insidethemes/mytheme/skeleton.pt. - Set
theme = "mytheme"ingolem.tomlunder[build](or[tool.golem.build]inpyproject.toml).
Complete Annotated Custom Theme Example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>${title} - ${site_title}</title>
<meta name="generator" content="${generator_version}" />
<meta tal:condition="site_author" name="author" content="${site_author}" />
<link rel="canonical" tal:condition="site_url" href="${site_url}" />
<!-- External and Custom Stylesheets -->
<tal:block tal:repeat="css_file custom_css">
<link rel="stylesheet" href="${css_file}" />
</tal:block>
<!-- Theme Stylesheet -->
<link rel="stylesheet" href="/static/css/theme.css" />
</head>
<body>
<header class="site-header">
<div class="header-container">
<a href="/" tal:attributes="href site_url or '/'" class="site-logo">${site_title}</a>
<span tal:condition="site_author" class="site-author">By ${site_author}</span>
</div>
</header>
<div class="layout-container">
<!-- Sidebar Navigation -->
<aside class="sidebar-nav">
<div tal:condition="nav_html" tal:replace="structure nav_html" />
<ul tal:condition="not:nav_html and nav_tree">
<li tal:repeat="item nav_tree">
<a href="${item.url}" tal:attributes="href item.url">${item.title}</a>
</li>
</ul>
</aside>
<!-- Main Document Body -->
<main class="content-body">
<h1 tal:condition="title">${title}</h1>
<div tal:content="structure body_html" />
</main>
<!-- Table of Contents -->
<aside class="sidebar-toc" tal:condition="toc_html">
<h3>On This Page</h3>
<div tal:content="structure toc_html" />
</aside>
</div>
<footer class="site-footer">
<p>Built with Golem ${generator_version}</p>
</footer>
<!-- Custom JavaScript Injections -->
<tal:block tal:repeat="js_file custom_js">
<script src="${js_file}"></script>
</tal:block>
</body>
</html>
METAL Slot Contracts & Layout Inheritance
Golem's built-in skeleton.pt template exposes the top-level macro layout and 6 specialized extension slots. Custom themes can either write an entirely custom template from scratch or inherit and selectively override individual slots using metal:use-macro and metal:fill-slot.
Slot Name | Target Element | Contract & Usage |
|
| Document |
|
| Global site branding header bar containing the site title link ( |
|
| Left sidebar navigation panel.
The default implementation renders inside a collapsible |
|
| Main document article reading pane.
Houses breadcrumb navigation ( |
|
| Right-hand on-page Table of Contents sidebar.
Displays the "On This Page" heading and the rendered heading list ( |
|
| Document footer bar.
Renders git repository "Edit this page" links ( |
Extending Default Slots with metal:use-macro
To customize specific regions without duplicating the entire HTML5 structure, a theme template can use the default macro and fill only the desired slots:
<!DOCTYPE html>
<html lang="en" metal:use-macro="default_layout">
<!-- Customize header to include logo and repository link -->
<header id="golem-header" class="golem-header custom-header" metal:fill-slot="header">
<div class="brand">
<img src="/static/images/logo.svg" alt="Logo" class="logo" />
<a href="./" tal:attributes="href site_url or root_path">${site_title}</a>
</div>
<div class="header-actions" tal:condition="source_repo_url | nothing">
<a href="${source_repo_url}" class="repo-link" target="_blank" rel="noopener noreferrer">GitHub</a>
</div>
</header>
<!-- Customize footer with copyright and custom links -->
<footer id="golem-footer" class="golem-footer" metal:fill-slot="footer">
<div tal:condition="source_edit_url | nothing" class="golem-source-links">
<a href="${source_edit_url}" target="_blank" rel="noopener noreferrer">Edit this page</a>
</div>
<p class="copyright">© 2026 Acme Corp. All rights reserved. Powered by Golem ${generator_version}.</p>
</footer>
</html>
Distributing Reusable Themes via Python Packages
You can distribute Golem themes as reusable Python packages. Register your theme directory in pyproject.toml using entry points:
[project.entry-points."golem.themes"]
mytheme = "my_theme_package"
When installed, users can select your theme simply by setting theme = "mytheme" in their golem.toml.
- TAL
Template Attribute Language. An XML-attribute-based language used by Chameleon to declare conditional rendering, repetition, and content injection directly in HTML/XML markup.
- METAL
Macro Expansion for TAL. The METAL namespace allows Chameleon templates to define reusable layout slots (
metal:define-slot) and fill them from page templates (metal:fill-slot).- ZPT (Zope Page Templates)
The template format combining TAL and METAL, originating in the Zope web framework. Chameleon implements ZPT with significant performance improvements via compilation.
- Chameleon
A fast, compiled Zope Page Templates engine. Golem uses Chameleon to render
skeleton.ptand any custom theme templates.- skeleton.pt
The primary Chameleon template file (
skeleton.pt) that defines the full HTML page layout for a Golem site, including head metadata, navigation, content area, and footer slots.