WebGen-R1: Incentivizing Large Language Models to Generate Functional and Aesthetic Websites with Reinforcement Learning

Paper · arXiv 2604.20398 · Published April 22, 2026
RL with Verifiable Rewards (RLVR)

While Large Language Models (LLMs) excel at function-level code generation, project-level tasks such as generating functional and visually aesthetic multi-page websites remain highly challenging. Existing works are often limited to single-page static websites, while agentic frameworks typically rely on multi-turn execution with proprietary models, leading to substantial token costs, high latency, and brittle integration. Training a small LLM end-to-end with reinforcement learning (RL) is a promising alternative, yet it faces a critical bottleneck in designing reliable and computationally feasible rewards for website generation. Unlike single-file coding tasks that can be verified by unit tests, website generation requires evaluating inherently subjective aesthetics, cross-page interactions, and functional correctness. To this end, we propose WebGen-R1, an end-to-end RL framework tailored for project-level website generation. We first introduce a scaffold-driven structured generation paradigm that constrains the large open-ended action space and preserves architectural integrity. We then design a novel cascaded multimodal reward that seamlessly couples structural guarantees with execution-grounded functional feedback and vision-based aesthetic supervision. Extensive experiments demonstrate that our WebGen-R1 substantially transforms a 7B base model from generating nearly nonfunctional websites into producing deployable, aesthetically aligned multi-page websites. Remarkably, our WebGen-R1 not only consistently outperforms heavily scaled open-source models (up to 72B), but also rivals the stateof-the-art DeepSeek-R1 (671B) in functional success, while substantially exceeding it in valid rendering and aesthetic alignment. These results position WebGen-R1 as a viable path for scaling small open models from function-level code generation to project-level web application generation. To facilitate future research, we release our code and data at https://github.com/juyongjiang/WebGen-R1.

Introduction. Recent advances in Large Language Models (LLMs) have significantly expanded their capabilities in automated code generation [17, 15, 10, 43, 49, 34, 18], achieving human-competitive performance on function-level benchmarks [5, 25]. However, moving from generating isolated functions to architecting project-level software remains a frontier challenge [20, 4, 57, 52, 24, 19].

Among these challenges, end-to-end website generation, encompassing multi-page routing, dynamic functionality, modern user interface (UI) design, and responsive layouts, is particularly demanding [44, 48, 28, 54]. Unlike single-file coding tasks, real-world websites require consistent architectural patterns, multi-file codebases with intricate dependencies, long-range contextual coherence, and adherence to design principles that balance functionality with visual appeal. This requires reasoning not only over software engineering constraints but also over aesthetic and user-experience (UX) considerations, which have traditionally been difficult to formalize and evaluate in automated code generation.

Despite promising early progress, current approaches to LLM-driven website generation face significant scalability and quality limitations. One paradigm simplifies the task to single-page static sites [27], abstracting away the intricacies of modern web applications, such as dynamic routing, state management, authentication flows, and cross-page navigation in modern web applications. Conversely, multi-agent orchestration frameworks attempt to decompose the task by assigning different specialized sub-agents to implement discrete subtasks, such as UI layout, backend logic, and testing, and then integrating their outputs [13, 11, 12, 28]. However, such modularity introduces brittle inter-agent dependency chains, where small inconsistencies in contracts, file names, or interface definitions can cascade into non-functional builds. Although this issue can be mitigated through multi-turn execution with refined feedback, doing so results in substantial token costs and high latency. Furthermore, neither paradigm effectively optimizes for the intersection of functionality and aesthetics, often yielding websites that are technically executable but visually incoherent or functionally sterile.

To address these limitations, we propose WebGen-R1, a reinforcement learning (RL) framework designed to incentivize the end-to-end generation of functional and aesthetic multi-page websites. However, integrating RL into such open-ended generative tasks presents a critical bottleneck in designing a reward signal that is both reliable and computationally feasible [10, 53, 47, 50, 31]. Unlike single-file coding tasks that can be verified by unit tests, verifying a website’s functionality requires interacting with it, clicking buttons, navigating routes, and checking state changes. While deploying GUI agents for automated exploration seems promising, it is prohibitively expensive for RL training. The vast exploration space of web interactions, combined with the substantial token costs and high latency of multi-turn execution, introduces unacceptable cost and training delay. Moreover, the reliability of such agents is largely limited by the capabilities of their underlying models, often leading to noisy reward signals. Relying solely on visual inspection via Vision-Language Models (VLMs) also leaves an important gap, since a visually perfect interface may still conceal broken event handlers or invalid logic chains, rendering the page non-functional despite its appearance.

To resolve this dilemma, we first propose a scaffold-driven structured generation paradigm that constrains the large open-ended action space and preserves architectural integrity. Specifically, instead of generating the whole project from scratch, the LLM operates within a standardized, pre-validated React template. It generates and modifies components within this robust skeleton, ensuring that the fundamental build pipeline, routing architecture, and server configurations are inherently correct by design. Subsequently, we implement a rigorous filtering stage, namely a hierarchical verification and rendering pipeline, before costly reward modeling. This stage includes static compliance verification, which checks the required artifact/action structure, the presence of project files and commands, and selected content-level rules, followed by automated build and rendering. This step eliminates low-level execution errors and provides immediate, dense penalty signals for structural hallucinations. Built on this template-driven, statically verified foundation that strongly guarantees functionality and executability, we further propose a novel cascaded multimodal reward that leverages VLMs for semantic visual alignment. The VLM assesses the rendered website for aesthetic harmony, such as UI layout, typographic consistency, visual cues of functionality, and stylistic alignment with the user’s intent.

Related work. Large language models (LLMs) have demonstrated remarkable proficiency in function-level code generation, achieving near-human performance on function-level benchmarks [5, 2, 25, 34, 18]. Advances in instruction tuning [33, 46, 7, 45, 35] and tool-augmented prompting [36, 55] have further improved zero-shot and few-shot code generation capabilities. However, these achievements predominantly concern single-file or self-contained scripts, often constrained to producing one function or module per task. Such settings abstract away the complexities of real-world software engineering, where projects span multiple files, require intricate inter-module dependencies, and must satisfy both functional and non-functional requirements. Compared to function-level coding, project-level code generation poses qualitatively different challenges. Prior attempts to extend LLMs to multi-file outputs include hierarchical prompting [42, 55], iterative refinement [6, 32, 40], and agent-based pipelines [23, 56, 29]. In the context of web development, one line of work simplifies the task to single-page static sites [27], abstracting away the intricacies of modern web applications, such as dynamic routing, state management, authentication flows, and cross-page navigation. Multi-agent approaches [13, 11, 12, 28] partition functionality across specialized sub-agents, such as front-end generation, API design, and testing. However, integration often suffers from inconsistent shared states and fragile inter-component linking. In addition, multi-turn execution results in substantial token costs and high latency. These shortcomings may result in generated projects that build and run but still fail to align with the holistic end-to-end specifications of real-world websites. This work explores employing a small open-source LLM to generate project-level multi-page websites in an end-to-end manner, without relying on task decomposition or agent orchestration with proprietary models.

Reinforcement learning (RL) has emerged as a crucial technique for aligning LLM behavior with human preferences and task-specific objectives [33, 1, 3, 22]. Yet adapting RL to open-ended code generation introduces unique obstacles, including a vast action space, undefined or ambiguous ground truth, and outputs that cannot be trivially benchmarked against static gold standards. Reinforcement Learning with Verifiable Rewards (RLVR) [38, 10, 43, 51] addresses part of this issue through deterministic binary success checks, such as unit test pass rates, which work well for algorithmic correctness but fail to capture subjective quality dimensions such as style, maintainability, or visual experience.

Method. We formulate automated end-to-end website generation as a conditional structured generation problem under template constraints. Instead of generating the whole project from scratch, WebGen-R1 operates within a scaffold-driven structured generation paradigm based on a standardized, pre-validated React template. In this framework, the scaffold guarantees the structural integrity of the project, while the LLM is responsible for the semantic content and visual realization.

Let D denote the space of natural language specifications and W denote the space of valid website projects. A valid project W ∈W is defined as a tuple W = ⟨G, Φ⟩, where G = (V, E) represents the directory graph structure, with nodes V as files or folders and edges E as import dependencies, and Φ = {fv}v∈V denotes the semantic content of each file. To reduce the brittle dependency chains common in multi-page website generation, we introduce a fixed template manifold T . The template defines an invariant subgraph GT ⊂G that contains the build configuration, routing skeleton, and server-side logic. The policy πθ is restricted to generating the variable components outside the fixed scaffold, denoted by ∆= W \ T . Formally, given a system prompt S, a user prompt x ∈D, and the template context T , website generation is modeled as: Wgen = T ⊕πθ(∆| S, x, T ), (1) where ⊕denotes the injection of generated component code into predefined scaffold slots. The policy πθ is factorized autoregressively over the tokens of the variable components:

To eliminate low-level execution errors, we introduce a rigorous filtering stage before costly reward modeling. We model the environment transition as a composite function H : W →O that maps a generated project to an observation state o. This process is composed of two distinct phases as follows.

Phase I. Static Compliance Verification. Before execution, the generated website Wgen undergoes a static validation procedure Istatic(·). We define a set of constraints C = {cstructure, cfiles, ccommands, ccontent}, which verify compliance with the required website structure, the presence of project files and commands, and selected content-level rules such as valid “package.json” fields and component export patterns. The static validation procedure is formally defined as:

Phase II. Automated Build and Rendering. If Istatic = 1, the project enters the execution environment Eenv. In our setup, this stage is implemented as a deterministic pipeline: o = Rrender (Lserve (Bbundler (Iinstall(Wgen)))) , (4) where I resolves package dependencies, B executes the build script such as Vite or Webpack, L starts the local server, and R captures the visual state with a headless browser. The resulting observation o is a tuple: o = ⟨{Ip}p∈P, Λruntime, Λconsole⟩, (5) where {Ip}p∈P denotes screenshots over a set of routes P, and Λruntime and Λconsole denote runtime logs and browser console logs, respectively.

Designing a reliable and computationally feasible reward model for website generation is challenging because functional correctness depends on objective rule-based verification, while aesthetic quality and user experience (UX) depend on subjective and continuous perceptual assessment. To address this challenge, we propose a cascaded multimodal reward R(Wgen, o, x) that strictly penalizes structural failures while incentivizing aesthetic alignment, including UI layout, typographic consistency, visual functional correctness, and stylistic alignment with the user’s intent, via Vision-Language Models (VLMs). Formally, the total reward is computed hierarchically:

• Aesthetic Perception Score (svis). We employ a VLM as a proxy for human preference judgment. The VLM processes the rendered screenshots {Ip}p∈P together with the prompt x and outputs a scalar score svis ∈[0, 5]. This score reflects layout harmony, color palettes, typographic hierarchy, visually observable functional quality, and stylistic alignment with the user’s intent.

Conclusion. In this work, we introduce WebGen-R1, a reinforcement learning framework that enables small open-source LLMs to generate entire multi-page websites in an end-to-end manner while meeting both functional and aesthetic requirements. We propose a scaffold-driven structured generation paradigm with a hierarchical verification and rendering pipeline, ensuring high functional reliability without the prohibitive cost of GUI-agent exploration. We then design a cascaded multimodal reward model that seamlessly couples structural guarantees with execution-grounded functional feedback and vision-based aesthetic supervision, aligning the optimization objectives with human standards for both functional correctness and visual design. Extensive experiments on two real-world benchmarks demonstrate that our WebGen-R1 consistently improves functional robustness, visual coherence, and deployability, surpassing or matching advanced proprietary and open-source models. We believe these insights open new directions for end-to-end RL training in full-stack application development, and we release all resources to support future research in this emerging area.

Lines of inquiry this paper opens 24

Research framings built by reading the notes related to this paper — the questions it feeds into.

Can visual rendering-based rewards effectively improve code and layout quality? How do parameter-efficient methods maintain performance while reducing training cost? How does ChatGPT adoption vary across users and contexts? Can AI systems formally evaluate design quality and taste? How important is reward engineering relative to pretraining for reasoning? How can reward models overcome their inherent blindspots and biases?