Skip to content
Honmaple
Documentation navigation

Themes

On this page

Themes define your site's appearance with templates, static resources, and configuration.

Select a Theme

theme: "mytheme"

This selects themes/mytheme/.

Directory Layout

themes/mytheme/
├── theme.yaml              # Optional configuration
├── templates/
│   ├── index.html          # Home
│   ├── page.html           # Page
│   ├── section.html        # Section
│   ├── taxonomy_list.html
│   ├── taxonomy_single.html
│   └── shortcodes/
│       └── youtube.html
├── static/
│   ├── css/
│   ├── js/
│   └── images/
└── i18n/
    ├── en.yaml
    └── zh.yaml

Use these standard directory names.

Theme Configuration

A theme.yaml, theme.toml, or theme.json file at the theme root supplies defaults:

# themes/mytheme/theme.yaml
name: "MyTheme"
version: "1.0.0"
description: "A minimal theme"
author: "honmaple"
params:
  mytheme_primary_color: "#333"

Existing site settings are not overridden.

Template Precedence

Templates are looked up in this order:

  1. The site's templates/ directory.
  2. The selected theme's templates/ directory.
  3. The built-in theme's templates/ directory.

To override a theme template, create a file at the same relative path in the site:

mysite/
├── templates/
│   └── page.html           # Overrides the theme
└── themes/
    └── mytheme/
        └── templates/
            ├── index.html
            └── page.html

Static File Precedence

Site static/ files take precedence over theme static/ files with the same path.

A Minimal Theme

themes/simple/
├── theme.yaml
├── templates/
│   ├── index.html
│   └── page.html
└── static/
    └── css/
        └── style.css

index.html

<!DOCTYPE html>
<html lang="{{ config.language }}">
<head>
  <meta charset="utf-8">
  <title>{{ config.title }}</title>
  <link rel="stylesheet" href="{{ config.base_url }}/css/style.css">
</head>
<body>
  <h1>{{ config.title }}</h1>
  {% for section in sections %}
  <section>
    <h2><a href="{{ section.Path }}">{{ section.Title }}</a></h2>
    <ul>
      {% for page in section.Pages %}
      <li><a href="{{ page.Path }}">{{ page.Title }}</a></li>
      {% endfor %}
    </ul>
  </section>
  {% endfor %}
</body>
</html>

page.html

<!DOCTYPE html>
<html lang="{{ page.Lang }}">
<head>
  <meta charset="utf-8">
  <title>{{ page.Title }} - {{ config.title }}</title>
  <link rel="stylesheet" href="{{ config.base_url }}/css/style.css">
</head>
<body>
  <article>
    <h1>{{ page.Title }}</h1>
    <time>{{ page.Date | date:"2006-01-02" }}</time>
    <div>{{ page.Content | safe }}</div>
  </article>
</body>
</html>