ianm / html-head
Add custom items to the HTML <head> attributes
Package info
Language:TypeScript
Type:flarum-extension
pkg:composer/ianm/html-head
Fund package maintenance!
Requires
- flarum/core: ^2.0.0
Requires (Dev)
- flarum/phpstan: ^2.0.0
- flarum/testing: ^2.0.0
This package is auto-updated.
Last update: 2026-04-12 10:36:09 UTC
README
A Flarum extension that gives forum administrators full control over custom tags injected into the HTML of their forum — without touching code or config files.
Features
- Structured tag types — dedicated forms for
<meta>,<link>,<script>,<style>, and raw HTML, with type-aware fields and validation for each - Inject into head or body — choose per item whether it is injected into
<head>or before</body> - Target forum, admin, or both — each item can be scoped to the forum frontend, the admin panel, or both
- Automatic preconnect hints —
<link rel="preconnect">and<link rel="dns-prefetch">hints are automatically generated for any cross-origin<link>or<script>tags, warming the connection before the browser needs it - Save-time rendering — HTML is rendered and cached when you save, not on every page request; no database queries on the hot path
- Live preview — the modal shows a real-time preview of the exact HTML tag that will be injected as you fill in the fields
- Sort order — drag items into the order you need them injected
- Clean admin UI — searchable table with colour-coded type, location and page badges; icon buttons for edit and delete
Tag types
| Type | What it does |
|---|---|
| Meta | Standard name/content or Open Graph property/content meta tags |
| Link | <link> tags with guided fields for rel, href, as, fetchpriority, crossorigin, and any additional attributes (e.g. sizes, hreflang, media) |
| Script | External <script src> with defer/async/module/crossorigin options, or inline <script> blocks |
| Style | Inline <style> blocks |
| Raw HTML | Freeform HTML for anything that doesn't fit the above |
Performance
Items are rendered to HTML at save time and stored in two cache keys (one per injection location). On page load, AddHeaders reads from cache only — no database queries, no per-request rendering. When an item is created, updated, or deleted, only the affected cache keys are invalidated and synchronously rebuilt.
Cross-origin <link> and <script> tags automatically get preconnect and dns-prefetch hints prepended, reducing connection setup latency for external resources.
Installation
composer require ianm/html-head:"*"
php flarum migrate
php flarum assets:publish
Updating
composer update ianm/html-head php flarum migrate php flarum cache:clear
Links
Support
Please consider supporting my extension development and maintenance work.