PureWiki utilizes a straightforward, PHP-based templating system for rendering the public frontend. This system prioritizes simplicity and performance over complex template languages like Twig or Blade.

Architecture

Themes are located in the themes/ directory. The core layout file is always named page.php.

Directory Structure

themes/default/
├── page.php          # Main layout file
├── other-layout.php  # Optional: further layouts, selectable per page
├── elements/         # Reusable HTML snippets
│   ├── header.php
│   ├── content.php
│   └── footer.php
├── style.css         # Stylesheet
├── script.js         # Theme script
└── theme.json        # Optional: adjustable theme colors
Performance Tip:
When including static snippets like header.php, use echo file_get_contents(__DIR__ . '/path') to minimize PHP parsing overhead.

Placeholders and Variables

Placeholders are denoted by {{ variable_name }}. The renderer replaces these during the build process.

Available System Variables

Conditional Logic

The renderer supports simple {{ if variable }} and {{ endif }} blocks.

{{ if show_left_sidebar }}
  <aside>
    {{ virtual:left_sidebar }}
  </aside>
{{ endif }}

Virtual Pages and Macros

Themes rely on Virtual Pages ({{ virtual:name }}) for global content and Macros ({{ macro:name }}) for dynamic logic like search or navigation.

Layout Templates

Besides page.php, a theme can contain more layout files. The Layout Template setting of a page selects the file by name, see Page Settings. If the file does not exist, page.php is used.

Theme Colors

A theme can offer colors that administrators change under Global Settings > Appearance > Theme Colors, separately for light and dark mode. The colors are declared in theme.json:

{
    "colors": {
        "--pw-primary": {
            "label": "settings.theme_color_primary",
            "light": "#0172ad",
            "dark": "#3fa9dd"
        }
    }
}

For every color that differs from its default, PureWiki adds an override to the head, for example :root{--pw-primary:light-dark(#ff0000,#ff4242)}. The stylesheet therefore has to use the variable and set color-scheme so light-dark() works. A theme without theme.json has no adjustable colors.

Default Theme

The default theme is written in plain CSS without a framework. It reads its design from CSS variables in :root. The adjustable base colors are the source for derived colors, which follow automatically when a color changes.

Variable Description
--pw-primary Accent color for buttons, link hover, focus and active states. Adjustable.
--pw-bg / --pw-fg Background and text color. Adjustable.
--pw-surface, --pw-border, --pw-muted Derived from background and text.
--pw-color-info, -success, -warning, -important Status colors for callouts and messages.
--pw-radius, --pw-spacing, --pw-container-width, --pw-header-height Shape and layout.
--pw-font-sans, --pw-font-mono Font stacks.

Light and dark mode use light-dark(). Without a choice, the theme follows the system setting. The toggle in the header sets data-theme="light" or data-theme="dark" on the <html> element and stores the choice in the browser. Custom CSS and landing pages can use the same variables.

Minified files:
The default theme loads style.min.css and script.min.js. There is no build step. After editing style.css or script.js, create the minified files with a minifier of your choice.
Previous default theme:
The former PicoCSS-based theme is still available as default_picocss and can be selected under Global Settings > Appearance.