How to convert HTML to Twig templates
A step-by-step guide to converting a static HTML/CSS design into Twig templates - variable mapping, conditional blocks, layout inheritance, and how to automate the whole process.
Guides
Converting a static HTML/CSS design into Twig templates is one of the most common frontend-to-backend handoff tasks in PHP projects. Whether you're delivering to a Symfony developer, integrating with Drupal's theme layer, or building a standalone Twig-based site, the conversion process follows the same pattern.
A static HTML file has hard-coded values everywhere: headlines, image paths, text strings. Twig templates replace those with variables: {{ fm.props.headline }}, {% if fm.props.imageUrl %}, {% for item in fm.data.products %}. The HTML structure stays identical - only the dynamic parts change.
The full conversion involves identifying which values are dynamic versus static, replacing them with named Twig variables under a consistent namespace, wrapping optional blocks in {% if %} conditions, splitting the HTML into partials, layouts, and page templates, and documenting the variable contract so the backend developer knows what to pass. Done manually on a 10-component design, this takes several hours and produces output that varies in naming and structure depending on who does it.
Astro's component model - typed Props interfaces, explicit slots, no runtime by default - maps directly and mechanically to Twig. Required props become required variables. Optional props become {% if %} blocks. Slots become {% block %} regions. The mapping is deterministic. Structuring your design as a constrained Astro project before the Twig conversion gives you a typed, validated intermediate representation. Frontmatter Solo reads that Astro project and generates the Twig output automatically - partials, layouts, pages, a variable manifest, and an INTEGRATION.md that documents every variable the backend needs to populate.
The generated Twig output follows generic Twig conventions and works with Symfony, Drupal, Craft CMS, Statamic, and standalone Twig. Frontmatter Solo is the automation layer: one command, documented contract, backend-friendly output.
A step-by-step guide to converting a static HTML/CSS design into Twig templates - variable mapping, conditional blocks, layout inheritance, and how to automate the whole process.
A step-by-step breakdown of what it takes to turn Astro components into Twig partials — manually, and with a build-time tool.
How to hand off an Astro project to a Symfony developer — Twig templates, controller variables, and the integration pattern that keeps both sides clean.
What a proper Astro-to-backend handoff looks like, what usually goes wrong, and how to structure it so the backend developer can start immediately.
The handoff is not a backend problem. It's a frontend artifact — and the frontend developer is the only one positioned to generate it correctly.