Theme Development
This guide is the practical entry point for building and maintaining frontend themes in Pagify.
For strict schema and runtime rules, see the contract:
Theme location and baseline
A frontend theme lives under:
themes/main/{theme-slug}
Minimum structure:
themes/main/{slug}/
theme.json
README.md
assets/
js/
css/
img/
pages/
home.json
lang/
en/theme.php
vi/theme.php
Start from a new theme
Create a theme scaffold:
php artisan cms:make-theme "My Theme"
Then review and update:
theme.jsonmetadata and version.pages/home.jsonhomepage WSRE document.- Assets and localization files.
Manifest essentials (theme.json)
Required fields:
slugnameversion
Recommended fields:
descriptionauthorrequiressupportsrender.engine = wsre
Important rule: theme.json.slug must match folder name.
WSRE document workflow
1. Build page document
Use pages/home.json with WSRE nodes:
head: meta/title/script/link nodesbody: HTML-like nodes or dynamic resolvers- optional
layout_html: shell containing{{ head }}and{{ content }}placeholders
Example minimal page:
{
"version": 1,
"engine": "wsre",
"head": [
{ "tag": "title", "text": "My Theme" }
],
"body": [
{
"tag": "main",
"children": [
{ "tag": "h1", "text": "Welcome" }
]
}
]
}
2. Add route-based pages
Start with pages/home.json, then add:
pages/about.jsonfor/aboutpages/blog/index.jsonfor/blog
3. Add assets
Store assets in:
assets/cssassets/jsassets/img
Use asset URL pattern:
/theme-assets/{theme-slug}/css/app.css
/theme-assets/{theme-slug}/js/app.js
4. Add localization
Provide translation files:
lang/en/theme.phplang/vi/theme.php
Localization files can still be consumed by backend/domain services when needed.
Runtime behavior you must validate
Theme resolution order for frontend rendering:
- Active theme of current site
- Fallback theme (
FRONTEND_THEME_FALLBACK) - Default theme (
FRONTEND_THEME)
If no valid page document is found across fallback chain, runtime will continue with next source and may eventually fall back to page-builder published output.
Extension points and helpers
Themes can consume platform helpers and plugin-injected helpers.
For helper-hook contract and subscriber example:
QA and release checklist
- Validate
theme.jsonsyntax and slug matching. - Activate theme in Admin and verify render on target site.
- Verify fallback behavior by simulating missing template/invalid manifest.
- Validate all
asset_urlreferences and cache-busting output. - Clear caches and retest:
php artisan optimize:clear
- Run smoke tests and key frontend regression cases.
Troubleshooting
Theme not listed in manager:
- check
theme.jsonexistence and validity - check slug-folder mismatch
Theme selected but not rendering:
- check
pages/home.json - check fallback/default theme validity
- clear framework cache
Asset file changes not visible:
- confirm correct path under
assets/* - clear cache and verify cache-busting strategy