Head tags injection
Inject tags at runtime
Add analytics, verification, and preview tags without rebuilding. Supply base64-encoded tags via environment; the backend injects them just before \u003C/head\u003E
on /app/*
routes.
Quickstart
- Ensure module is enabled: set
MODULES_ENABLED=html_inject
(or include it among others). - (Optional) Control the module via
FEATURE_HTML_INJECT=true
(defaults to on). - Provide your tags via base64 in
INJECT_HEAD_TAGS
. - Open your app:
/app/
. The core server serves the SPA index and runs a transform pipeline; this module injects the head tags and core injects envs.
Examples
Tags are comma-separated before encoding. Common use-cases:
Google site verification
<meta name="google-site-verification" content="your-token">
Analytics script
<script src="https://example.com/analytics.js" defer></script>
To set the env, join your tags with commas, then base64-encode the whole string. Example (bash):
export INJECT_HEAD_TAGS=$(echo -n '<meta name="google-site-verification" content="TOKEN">,<script src="https://cdn.example.com/app.js" defer></script>' | base64)
How it works
- Module id:
html_inject
. Enable withMODULES_ENABLED=html_inject
. - Core registers a transform that injects a small
window.__envs__
block for selected envs (FEATURE_*, VITE_*, MODULES_ENABLED). - The
html_inject
module registers a transform; ifINJECT_HEAD_TAGS
is set, it decodes and injects tags just before\u003C/head\u003E
. - Plays nicely with the reusable Handlebars head partial used by docs and landing pages.
Environment variables
FEATURE_HTML_INJECT
(optional): toggle the module; defaults to enabled.INJECT_HEAD_TAGS
(optional): base64-encoded, comma-separated list of tags to inject.
Notes & tips
- Use for temporary scripts and verification. For permanent assets/meta, prefer editing the
src/templates/partials/head.hbs
partial. - Works alongside the Static Pages engine and the SPA served at
/app/*
.