# Site Builder Workflow - Explanation & Fix ## The Problem (FIXED) You were experiencing confusion because there were **TWO separate systems** that weren't properly connected: 1. **Page Blueprint** (`PageBlueprint.blocks_json`) - Contains placeholder/sample blocks from AI structure generation 2. **Writer Content** (`Content` model) - Contains actual generated content from Writer tasks **The disconnect**: When deploying a site, it only used `PageBlueprint.blocks_json` (placeholders), NOT the actual `Content` from Writer. ## Current Workflow (How It Works Now) ### Step 1: Structure Generation - AI generates site structure → Creates `SiteBlueprint` with `PageBlueprint` pages - Each `PageBlueprint` has `blocks_json` with **placeholder/sample blocks** ### Step 2: Content Generation - Pages are sent to Writer as `Tasks` (title pattern: `[Site Builder] {Page Title}`) - Writer generates actual content → Creates `Content` records - `Content` has `html_content` and `json_blocks` with **real content** ### Step 3: Publishing Status - **Page Blueprint Status** (`PageBlueprint.status`): Set to `'published'` in Page Manager - Controls if page appears in navigation and is accessible - **Content Status** (`Content.status`): Set to `'publish'` in Content Manager - Controls if actual written content is used (vs placeholders) ### Step 4: Deployment (FIXED) - When you deploy, `SitesRendererAdapter._build_site_definition()` now: 1. For each page, finds the associated Writer Task (by title pattern) 2. Finds the Content record for that task 3. **If Content exists and status is 'publish'**, uses `Content.json_blocks` instead of `PageBlueprint.blocks_json` 4. If Content has `html_content` but no `json_blocks`, converts it to a text block 5. Uses the merged/actual content blocks for deployment ## URLs - **Public Site URL**: `https://sites.igny8.com/{siteSlug}` - Shows deployed site with actual content (if Content is published) - Falls back to blueprint placeholders if Content not published - **Individual Pages**: `https://sites.igny8.com/{siteSlug}/{pageSlug}` - Example: `https://sites.igny8.com/auto-g8/products` ## How To Use It Now 1. **Generate Structure**: Create site blueprint with pages (has placeholder blocks) 2. **Generate Content**: Pages → Tasks → Content (Writer generates real content) 3. **Publish Content**: In Content Manager, set Content status to `'publish'` 4. **Publish Pages**: In Page Manager, set Page status to `'published'` (for navigation) 5. **Deploy Site**: Deploy the blueprint - it will automatically use published Content ## What Changed ✅ **Fixed**: `SitesRendererAdapter._build_site_definition()` now merges published Content into PageBlueprint blocks during deployment ✅ **Result**: When you deploy, the site shows actual written content, not placeholders ## Important Notes - **Two Statuses**: Page status controls visibility, Content status controls which content is used - **Deployment Required**: After publishing Content, you need to **redeploy** the site for changes to appear - **Content Takes Precedence**: If Content is published, it replaces blueprint placeholders - **Fallback**: If Content not published, blueprint placeholders are used