LLM-Powered Page Generation: Practices and Troubleshooting Guide

    This article examines why generating pages with large language models often fails to produce deliverable results, even when the model can run the workflow and call skills. It breaks down four common failure modes—vague goals, state drift in long tasks, inconsistent asset paths, and the lack of executable validation—and presents a reusable engineering approach: structured contracts, staged generation, automated validation loops, and context/cost control. Readers will find an acceptance checklist and efficiency metrics for turning one-hour trial-and-error cycles into predictable delivery.

    1. Background: Why “It Generates” Is Not “It Ships”

    Over the past year, large language models with long context windows and Mixture-of-Experts (MoE) architectures have been widely used for code and page generation. A typical configuration has hundreds of billions of total parameters but only tens of billions of activated parameters, paired with a context window around 256K and a call cost clearly lower than flagship models. On paper, this looks well suited to batch generation. But the moment the task scales from “write a function” to “generate a complete set of HTML pages from a long document,” the problems surface quickly: the model can run the flow, understand intent, and invoke skills, yet it struggles to deliver an acceptable result in one pass.

    A typical test went like this. The source document and an image were placed in the same project directory. Using identical skill configuration and prompts, the model was asked to generate multiple HTML pages. The first round took over six minutes and only the home page rendered correctly; the rest were blank. After a follow-up prompt, the second round took over fifteen minutes and most pages had styling issues. After pointing out the problems with screenshots, the third round stalled; after interrupting and restarting, it continued and reported the fixes complete after roughly another fourteen minutes, but the styling issues remained, and pages that were not called out were never checked. The fourth round took twenty-four minutes and still had components shifted as a whole and content cut off. After more than an hour in total, the result was still not acceptable.

    This is not a single bug but a stack of three engineering problems: generation goals that cannot be measured, missing context and state management, and the absence of automated regression checks.

    2. Root Causes: Four Failure Modes

    1. False completion from vague goals. The prompt only said “generate pages” without defining the page list, viewport sizes, asset paths, or acceptance criteria, so the model treated “files written” as the completion signal.
    2. State drift in long tasks. Across multiple repair rounds, the model focused only on the局部 flagged by screenshots and lacked a global checklist, so pages that were not named were skipped.
    3. Inconsistent assets and paths. Relative paths for images, styles, and scripts were changed during repeated rewrites; blank pages often came from failed asset loading rather than layout logic.
    4. No executable validation. “Renders successfully, no overflow, no overlap” was never turned into automated assertions, leaving only manual screenshot review with a long and unstable feedback loop.

    3. A Reusable Engineering Approach

    3.1 Replace natural-language wishes with a structured contract

    Write requirements as a machine-checkable list, for example a page list and acceptance table:

    1. {
    2. "pages": [
    3. {"id": "p1", "title": "Cover", "must_have": ["hero", "cta"]},
    4. {"id": "p2", "title": "Body", "must_have": ["toc", "figure"]}
    5. ],
    6. "assets": {"figure": "/assets/cover.png"},
    7. "viewports": ["1440x900", "768x1024"],
    8. "acceptance": ["no_horizontal_scroll", "no_overlap", "all_assets_200"]
    9. }

    The contract turns “looks good” into decidable items. Each round, the model must self-check every item and output a checklist.

    3.2 Generate in stages: skeleton first, styling later

    Split the work into four steps: first produce the page structure and routing, then fill in content and asset references, then apply design tokens (colors, spacing, font sizes) uniformly, and finally handle responsive adaptation. Each step should output a change summary to avoid losing state from rewriting all files at once.

    3.3 Replace manual screenshot review with an automated validation loop

    Add a minimal validation script locally to lock in rendering and assertions:

    1. // Example: check asset reachability and horizontal overflow
    2. const res = await fetch('/assets/cover.png');
    3. if (!res.ok) throw new Error('asset missing');
    4. const overflow = await page.evaluate(
    5. () => document.documentElement.scrollWidth > window.innerWidth + 1
    6. );
    7. if (overflow) throw new Error('horizontal overflow');

    Combined with general capabilities such as logging services and monitoring/alerting, record the key metrics of each round (elapsed time, number of failed assertions, repair rounds) to build a trend dashboard.

    3.4 Control context and cost

    A long context is not the same as an effective context. Inject only the contract, the current step’s output, and the failed assertions; move large blocks of historical HTML to on-demand retrieval. Use cached billing and batching to lower call costs, and spend the budget on the rounds that matter.

    4. Acceptance Checklist and Efficiency Metrics

    • The first screen and all pages render successfully under both viewports, with no blank pages;
    • All asset requests return success, with paths managed uniformly by build artifacts;
    • No horizontal scrolling, no components out of bounds, no text overlap;
    • Every repair round must include a checklist, with failed items explicitly marked;
    • Track the number of rounds and total elapsed time for one delivery as a baseline for iterating on the model and prompts.

    5. Conclusion

    For page generation tasks, the bottleneck has shifted from “can the model write it” to “can the team define and verify it.” By making requirements contractual, the process staged, and validation automated, you can compress hour-long trial-and-error into a predictable delivery rhythm—even with different large language models or AI coding tools. To host the generated artifacts and logs, you can combine general cloud capabilities such as object storage and container platforms to build a stable engineering loop.