Standard Theme Directory Layout
A typical Halo theme follows this structure:Required Files
theme.yaml
The theme manifest is the only required file. It must be placed at the root of the theme directory.theme.yaml
The
metadata.name field must be unique across all installed themes and should match the theme directory name.templates/ Directory
This directory contains all Thymeleaf template files. At minimum, you should provide anindex.html template for the homepage.
Theme Assets Location
Static assets must be placed in thetemplates/assets/ directory. This is enforced by Halo’s asset resolution mechanism:
application/src/main/java/run/halo/app/theme/config/ThemeWebFluxConfigurer.java
Asset Directory Structure
Organize your assets logically:Template Files
Core Templates
These templates correspond to the default template types defined by Halo:index.html - Homepage
index.html - Homepage
The main landing page of your site. Typically displays recent posts and featured content.
post.html - Single Post
post.html - Single Post
Template for displaying individual blog posts.Model variables:
post- The post data (PostVo)content- The post content (ContentVo)
page.html - Single Page
page.html - Single Page
Template for standalone pages.Model variables:
page- The page data (SinglePageVo)content- The page content (ContentVo)
category.html - Category Archive
category.html - Category Archive
Displays posts in a specific category.Model variables:
category- Category information (CategoryVo)posts- Posts in this category (ListResult of ListedPostVo)
archives.html - Post Archives
archives.html - Post Archives
Chronological archive of all posts.Model variables:
archives- Archive data grouped by year/month (ListResult of PostArchiveVo)
Custom Templates
You can define custom templates for posts, pages, and categories in your theme.yaml:theme.yaml
The
file field should be relative to the templates/ directory and must end with .html.Internationalization Structure
Thei18n/ directory contains resource bundles for multi-language support:
Property File Example
i18n/en.properties
Using in Templates
Settings Schema
Define configurable options for your theme:settings.yaml
If you include
settings.yaml, reference it in your theme.yaml by setting spec.settingName.Template Resolution
Halo resolves templates using theTemplateNameResolver interface:
api/src/main/java/run/halo/app/theme/TemplateNameResolver.java
- Check if a template exists in the active theme
- Fall back to default templates if not found
- Support custom templates per content type
Best Practices
Use Consistent Naming
Follow the default template naming convention for standard templates (
index.html, post.html, etc.).Organize Assets Logically
Keep CSS, JavaScript, images, and fonts in separate subdirectories under
templates/assets/.Provide Template Partials
Create reusable template fragments in a
partials/ or fragments/ directory:Example: Complete Theme Structure
Here’s a complete example of a well-organized theme:Next Steps
Templates
Learn how to develop Thymeleaf templates
Configuration
Configure your theme with theme.yaml