TUTORIAL
tutorial
6 min read

Build & Live-Reload a Theme (--dev-theme)

What you will build: A validated Format V1 theme scaffold running with live-reload against an isolated OpenDash site directory, ready to package into an installable .zip bundle or drop into themes/<slug>/.

Step 1: Scaffold, Live-Reload & Package

Generate a minimal full-document theme scaffold (theme.json, index.html, single.html, 404.html, assets/style.css) and mount it directly in dev mode:

Local Theme Dev Loop bash
opendash new theme my-theme --dir ./my-theme

mkdir -p ./dev-site
OPENDASH_SITE_ROOT=./dev-site OPENDASH_PORT=18767 \
  opendash serve --dev --dev-theme ./my-theme

Step 2: How --dev-theme & Error Overlay Work

When running with --dev --dev-theme <dir>, OpenDash mounts your theme directory directly without manual ZIP re-uploads:

  • Immediate Template Reload & Overlay: HTML templates, theme parts, blocks, and assets respond with no-store cache policy; C-SEC parse or MiniJinja errors surface an actionable diagnostic Error Overlay rather than failing silently.
  • Folder-Based Themes Without --dev: You can also place ready themes under <site_root>/themes/<slug>/ directly and activate or preview them with ?preview_theme=<slug>.
  • Manifest Sync Endpoint: Authenticated Admin sessions can invoke POST /api/admin/dev/sync to refresh theme declarations cleanly while keeping site options and content intact.

Step 3: Install, Activate & Upgrade Without Losing Data

Upload your validated .zip bundle under Appearance &rarr; Themes (Storage Format 2) and click Activate explicitly. Upgrading an installed theme replaces its package descriptor cleanly (PUT /api/admin/themes/package/{key} with If-Match: "pkg-<generation>") while preserving custom post types, entries, menus, media, and theme options.

Next Steps

Edit Source URL:

Search OpenDash

Use Arrow keys & Enter to navigate Full search page →