A Practical Guide to Website Generation with Open-Source LLM Agents
This article reframes "generate a website from a natural language prompt" as a general engineering problem rather than a benchmark score comparison. It walks through turning vague requests into verifiable specifications, layered prompt design, frontend trade-offs among animation, accessibility, and performance, concurrency-safe backend persistence, automated acceptance testing, and sandbox-based deployment with observability and cost control. It also lists common pitfalls and how to avoid them, showing how to reproduce the workflow on open-source models, self-hosted inference, and containerized environments.
1. From Benchmarks to Delivery: A Shift in Evaluation
The industry has traditionally judged models and agents by benchmark scores. Once agents take on real engineering work, however, the focus shifts from “answering the question correctly” to “finishing the job.” A usable deliverable has at least four layers: visual and brand expression, frontend interaction completeness, backend business logic correctness, and operability. If any layer is missing, the output is just a demo.
So this article does not discuss scores for any specific model or product. Instead, it abstracts “generating a runnable website from a natural language description” into a general engineering problem and lays out a reproducible path. The approach runs on a combination of open-source models, self-hosted inference services, and containerized sandboxes, and it can also connect to general capabilities such as container platforms, object storage, and log monitoring on Baidu AI Cloud.
2. Task Modeling: Breaking “Build a Website” into Verifiable Specifications
Vague requirements are the main source of failure. Convert the request into a structured specification first, then hand it to the agent:
- Site goal and audience: brand website / internal tool / campaign landing page;
- Information architecture: hero section, narrative timeline, parameter cards, content blocks, footer;
- Interaction list: seat selection, date selection, form validation, state locking;
- Data constraints: a maximum of 6 seats per flight, automatic locking when sold out, persistent reservations;
- Non-functional requirements: responsive breakpoints, accessibility, load performance, error fallbacks.
An illustrative specification snippet (YAML):
site:name: ORBITALsections: [hero_video, timeline, seat_map, booking, footer]constraints:seats_per_flight: 6on_full: lock_and_waitlistpersistence:store: relational_dbentities: [flight, seat, passenger, reservation]quality:a11y: WCAG AAresponsive: [360, 768, 1440]
Once the specification is fixed, so are the acceptance criteria, which avoids subjective judgments like “it looks right.”
3. Prompt Engineering: Layered Descriptions Instead of One Long Block
High-quality output depends on layered prompts, not a pile of adjectives:
- Role and constraints layer: tech stack, directory structure, code conventions, prohibited items;
- Structure layer: block order and the responsibility of each block;
- Visual layer: colors, typography, animation pacing, camera language (for example, the hero section sinks vertically from the sea surface, the frame splits top and bottom after crossing the waterline, and the gradient runs from light blue to deep navy);
- Data layer: entity relationships, fields, validation rules;
- Acceptance layer: the list of test cases that must pass.
The key technique is to pair “aesthetic descriptions” with “testable assertions.” For example, “the perfume bottle liquid rotates slowly and light passing through creates caustics” maps to “the hero animation shows no noticeable frame drops at 60fps and degrades gracefully under prefers-reduced-motion.”
4. Frontend Implementation: Balancing Animation, Accessibility, and Performance
Immersive hero sections often use full-screen video or Canvas rendering, but three risks must be handled: an oversized first-screen payload, decoding pressure on mobile, and missing accessibility. Practical recommendations:
- Provide multiple bitrates and a cover image for the video, and prioritize the low bitrate on first load;
- Use
IntersectionObserverto trigger scroll narratives on demand, avoiding all animations running at once; - Respect the system “reduce motion” preference and provide a static fallback;
- For critical interactions (the seat map), prefer SVG plus semantic tags to keep keyboard access working.
const mq = matchMedia('(prefers-reduced-motion: reduce)');if (mq.matches) document.body.classList.add('static-mode');const io = new IntersectionObserver((entries) => {entries.forEach(e => e.isIntersecting && e.target.classList.add('in-view'));}, { rootMargin: '200px' });document.querySelectorAll('[data-reveal]').forEach(el => io.observe(el));
5. Full-Stack and Data Persistence: Making “It Runs” a Hard Requirement
The real dividing line is the backend. Seat selection must be concurrency-safe, otherwise overselling is unavoidable. The general practice is a database-level unique constraint plus a transaction, rather than an application-level “read then write.”
CREATE TABLE reservation (id BIGSERIAL PRIMARY KEY,flight_id BIGINT NOT NULL,seat_no SMALLINT NOT NULL,passenger JSONB NOT NULL,created_at TIMESTAMPTZ DEFAULT now(),UNIQUE (flight_id, seat_no));
def book(flight_id, seat_no, passenger):with db.transaction():cur = db.execute("INSERT INTO reservation(flight_id, seat_no, passenger) ""VALUES(%s,%s,%s) RETURNING id",(flight_id, seat_no, passenger),)return cur.fetchone()[0] # Throws on unique conflict; the upper layer converts it to "seat already taken"
You also need idempotency keys to prevent duplicate submissions, request rate limiting, input validation, and delivery of reservation events to a message queue for asynchronous notifications.
6. Evaluation and Acceptance: Replacing Subjective Judgment with Automation
Set up three layers of checks:
- Static checks: type checking, linting, dependency vulnerability scanning;
- Functional cases: seat selection, sold-out locking, form validation, data still present after refresh;
- Experience regression: screenshot comparison across breakpoints, accessibility scanning, performance thresholds.
Sample cases:
1. Select 5 of 6 seats -> the 6th seat is still selectable2. Submit the same seat concurrently twice -> only 1 succeeds3. Refresh the page -> the reservation record still exists4. Disable motion preference -> the hero section is readable as static content
Only when every case is green is the release process allowed to proceed.
7. Engineering the Workflow: Sandboxes, Observability, and Cost Control
Agent-generated code needs to be built and run in an isolated sandbox to avoid polluting the host environment. Build artifacts go into a unified image registry, and a container platform orchestrates the release. After launch, connect log services and monitoring alerts, with thresholds for error rate, latency, and build duration. If you use a cloud inference service, wrap prompts and model calls in a replaceable adapter layer so you can run canary tests and cost comparisons across models, and archive build artifacts and screenshot baselines in object storage.
8. Common Pitfalls and How to Avoid Them
- Frontend only: the acceptance checklist must include backend cases;
- Visuals over usability: contrast, focus order, and form labels cannot be skipped;
- Ignoring concurrency: any “limited quantity” business needs a unique constraint as the backstop;
- Overly long prompts: layering plus examples beats piling on adjectives;
- No regression baseline: only checked-in screenshots and cases can prevent later changes from degrading the experience.
Conclusion
Treat “generating a website” as a delivery engineering task rather than a copywriting game. The core is three things: verifiable specifications, persistent data, and repeatable quality checks. Once you master this approach, you can reliably reproduce it in your own environment, whether for a commercial spaceflight timeline narrative, multi-screen content organization for a deep-sea institution, or a brand site with high aesthetic demands, and you can combine it with general cloud capabilities on Baidu AI Cloud to close the loop on deployment and operations.
