Lesson 3 · Affiliate websites
Build an affiliate website with Codex
Build and check a small static Astro publisher site with Codex, using a tested downloadable starter and a clear evidence boundary.
Run a static reference project, inspect its reader journey, make one controlled change and separate engineering checks from publication review.
Prerequisites: Bring a page brief from the keyword research and SEO lessons, working Codex access and Node 24.19.0. The Windows reference uses Astro 7.3.5; access, tool usage and hosting costs are separate from this free lesson.
Prepared with Codex; same-agent factual and editorial review. Research checked 2026-10-07.
In this lesson
Give Codex a reader task, researched inputs and clear checks. Build a few useful pages in a shared template, then inspect the result before expanding.
This lesson includes a downloadable Astro starter. It is a working engineering example with hypothetical gardening data, not a ready-to-publish shopping site.1
The workflow in four passes
- Brief
Choose one audience, the question each page answers and the evidence it needs.
- Build
Ask for static pages, shared components and visible unknowns.
- Check
Run tests, build the site and follow the actual reader journey.
- Research and release
Replace fixtures with reviewed facts; approve the real links and launch settings separately.
Bring the page brief from SEO for affiliate websites. If your ideas still overlap, revisit keyword research.
What you need
Open the working folder in the desktop app and choose Codex. The current official app guide describes selecting a project or folder and starting a Codex chat.2
| Item | Context for this lesson |
|---|---|
| Coding workspace | Built and executed by Codex in a Windows desktop workspace. App build number was not recorded.1 |
| Node and Astro | Tested with Node 24.19.0 and Astro 7.3.5. The starter pins these reference versions; they are not a claim about the latest releases.1 |
| CLI | Installed codex-cli 0.160.1 was version-checked. This walkthrough used the desktop workspace, not a separate CLI generation session.1 |
| Access and cost | Bring working Codex access and a local Node installation. This free lesson does not include tool usage, a domain or hosting. Check your own account limits and costs before starting. |
The command names below are terminal instructions. The prompts are instructions to Codex. You do not need to understand every generated line before starting, but you need to inspect the pages and the checks.
A tested hypothetical patio project
The starter has five content pages plus a 404. A floor-plan illustration and comparison table make its reader journey tangible; all product inputs and the program profile are explicitly fictional.1
| Page | Reader task | Evidence still needed for a real site |
|---|---|---|
| Home | Find the right starting point | Actual audience and available coverage |
| Size worksheet | Draw a bed footprint | Documented dimensions and placement constraints |
| Materials comparison | Compare consistent fields | Product evidence, costs and suitability limits |
| Demo program profile | See what to investigate | Current program terms, eligibility and an approved link |
| Relationship explanation | Understand this demo | Your real commercial relationships and required notices |
The illustrative 120 × 60 cm footprint is 0.72 m². Access space and placement remain unassessed. Do not turn an invented input into a product specification or safety recommendation.
Start from the working files
Download and extract the ZIP. Open its package folder, which contains package.json, in Codex. Read CONTENT_BRIEF.md and AGENTS.md.
Codex uses AGENTS.md for persistent project instructions. The official guide explains how global and directory instructions combine; keep project-specific rules close to the files they govern.3
Read CONTENT_BRIEF.md and AGENTS.md. Explain the reader journey
and the current evidence gaps. Keep the static Astro architecture,
the shared layout, visible Unknown values and construction controls.
Run the existing tests, build and generated-link checks.
Report actual results before changing the content.In the terminal inside the folder containing package.json, run:
npm ci
npm test
npm run build
npm run verify
npm run devThese scripts are included in this starter. verify is our generated-output check, not a built-in Astro command. The install downloads the locked dependencies; tests and build must finish successfully before inspection.1
Open the local address printed by Astro. dev serves the working project; build creates the static output; preview serves a completed build locally. A local preview is not production hosting.4
If you are building from an empty folder
Supply your own brief and ask for a small first implementation:
Build a fully static Astro publisher website from CONTENT_BRIEF.md.
Use one shared layout, ordinary internal links and one data file.
Create only the pages in the brief. Preserve missing facts as null
and display Unknown; do not invent rates, product tests or sources.
Include useful tables or diagrams where they clarify a decision.
Add tests for unknown values and approved outbound destinations,
plus a generated-output link check. Keep construction indexing
controls. Report commands run, versions and unresolved failures.
Do not deploy or create accounts.This prompt describes the bounded workflow used for the reference; it does not promise identical output from another session.
Astro creates routes from src/pages/, while reusable components and layouts keep presentation consistent across pages.5
| Starter location | Change it for |
|---|---|
| src/layouts/Base.astro | Shared document, navigation and footer |
| src/data/options.mjs | The illustrative comparison inputs |
| src/pages/ | The page-specific explanation and next action |
| src/lib/links.mjs | Unknown-value labels and approved link rules |
| test/ and scripts/verify.mjs | Behavior tests and generated-output checks |
Check behavior, not just whether it builds
The initial install needed local filesystem permission. Windows cleanup warnings remained in the successful install; tests and build passed. TEST_RESULTS.md records these limits and the local preview configuration.1
| Check actually run | What passed | What it cannot prove |
|---|---|---|
| Three behavior tests | Unknown differs from 0%; approved URLs retain parameters; unsafe or unapproved destinations are rejected | A merchant agreement, tracking accuracy or payout |
| Static build and output check | Six HTML files, existing internal destinations and assets, one main heading per page, construction controls, no page scripts | Search indexing, rankings or revenue |
| Local browser journey | Home → worksheet → comparison → profile → relationship explanation | Real product use, customer conversion or all-device accessibility |
The compensated-link test uses a demo URL in a test fixture. The site itself has no commercial outbound links or tracking IDs.1
For actual compensated links, Google documents rel=sponsored. This HTML attribute is separate from a readable relationship explanation; confirm the applicable notice and program rules before enabling your links.6
When a check fails, give Codex the exact error, the affected file and the expected behavior:
The comparison shows 0% for a missing commission.
Keep null as Unknown and preserve a genuine numeric zero as 0%.
Fix the display rule, add a regression test, then rerun the tests,
build and generated-link check. Explain the changed files.Make one controlled improvement
Change the hypothetical option A width from 120 to 150 cm in the fixture file. Ask Codex to update the worked example and its diagram consistently. With a 60 cm depth, the new illustrative footprint is 0.90 m².
Run the checks again, then compare the fixture, table, worksheet and diagram yourself. Passing tests only cover their assertions; our starter does not automatically prove that every measurement in prose and artwork matches.
Replace a fixture with a real option only after gathering its evidence. Keep unconfirmed program rates, attribution and tier-two rewards Unknown. Request a review of the facts and citations before adding further pages.
Publishing is a separate step
The starter produces dist/ for a static host. Cloudflare’s Astro Pages guide uses npm run build and dist as the build command and directory.4,7
This reference has no production domain, sitemap or approved commercial links. Its noindex and robots controls remain in place. The sample was tested locally; this lesson does not document a sample deployment or domain-connection test.
Use your project plan to finish the evidence, link, policy and launch review. Then publish deliberately and measure real outcomes.
Put it into practice
Your turn.
Extract the starter, open the folder containing package.json, and run the install, tests, build and output check. Follow the five-page reader journey. Change the hypothetical width to 150 cm and update the table, worksheet and diagram consistently; keep the 60 cm depth. Rerun checks and inspect all four representations.
Write down one actual failed or passed check, the command and version, and what it establishes. List the evidence still needed before replacing a fixture with a real option. Keep construction controls and inactive commercial links until the real launch review.
Check your thinking
150 cm × 60 cm is 0.90 m², using hypothetical measurements. Missing rates display Unknown; an actual numeric zero displays 0%. A successful build and generated-link check do not verify product facts, text/diagram agreement, merchant tracking, indexing or income. Compensation qualification, a readable relationship notice and your accepted program terms need separate review. Work in the folder that contains package.json; a local dev or preview server does not publish the site.