·1 min read
Generating production HTML from a prompt
"Build me a landing page for a bakery" is a great demo and a terrible spec. The interesting engineering is everything between the sentence and semantic, accessible markup you'd actually ship.
Constrain the model
Free-form HTML generation drifts. We constrain Gemini to a small vocabulary of Tailwind primitives and a fixed component grammar, then validate the output before it ever reaches the canvas.
const layout = await gemini.generate(prompt, {
grammar: TAILWIND_BLOCKS,
validate: assertSemantic,
});
The result: vendors describe a page in a sentence and edit from a real starting point — no hand-written markup, and nothing broken shipped.