Introduction
Halo themes are built using Thymeleaf templates and follow a structured extension-based architecture. This guide covers the essential concepts you need to start developing themes for Halo.What is a Halo Theme?
A Halo theme is a collection of templates, assets, and configuration files that define the visual presentation and layout of your Halo site. Themes are implemented as Kubernetes-style custom resources that extend the Halo platform.Key Concepts
Extension-Based Architecture
Extension-Based Architecture
Themes in Halo are defined as custom extensions using the GroupVersionKind (GVK) pattern:This allows themes to be managed as first-class resources within Halo.
Thymeleaf Template Engine
Thymeleaf Template Engine
Halo uses Thymeleaf as its template engine, providing powerful server-side rendering capabilities with natural template syntax.
Finder APIs
Finder APIs
Themes access data through Finder APIs - specialized services annotated with
@Finder that provide theme-safe data access methods.Theme Lifecycle
Themes go through several phases during their lifecycle:Installation
The theme is uploaded and extracted to the themes directory. Halo validates the theme manifest.
Configuration
The theme’s settings and configuration are loaded from
theme.yaml. If the theme defines settingName, a corresponding Setting resource is created.Activation
When activated, the theme becomes the active theme for the site. Only one theme can be active at a time.
Theme Status
Themes have a status that indicates their current state:Theme Phases
- READY: The theme is successfully installed and ready to use
- FAILED: The theme installation or validation failed
- UNKNOWN: The theme status is not yet determined
Essential Components
Every Halo theme consists of:theme.yaml
The manifest file that defines theme metadata, author information, and configuration
templates/
Directory containing Thymeleaf templates for rendering different page types
templates/assets/
Static assets like CSS, JavaScript, images, and fonts
i18n/
Internationalization resource bundles for multi-language support
Default Template Types
Halo defines standard template types that your theme should implement:api/src/main/java/run/halo/app/theme/DefaultTemplateEnum.java
While these are the default templates, themes can define custom templates for posts, pages, and categories through the
customTemplates configuration.Accessing Data in Templates
Themes access content through Finder APIs, which are Spring services marked with the@Finder annotation:
api/src/main/java/run/halo/app/theme/finders/Finder.java
Available Finders
postFinder- Access posts and archivescategoryFinder- Access categoriestagFinder- Access tagssinglePageFinder- Access standalone pagescommentFinder- Access commentsmenuFinder- Access navigation menuscontributorFinder- Access user informationpluginFinder- Access plugin informationthemeFinder- Access theme informationsiteStatsFinder- Access site statistics
Example: Simple Template
Here’s a basic example of a Halo theme template:templates/index.html
The
#theme.assets() expression is a special Halo function that generates the correct URL for theme assets, handling theme preview mode automatically.Next Steps
Theme Structure
Learn about the directory structure and file organization
Templates
Deep dive into Thymeleaf template development
Configuration
Configure your theme with theme.yaml
Assets
Manage CSS, JavaScript, and static resources