# Sites — Multi-Page Websites with AI

_Web Studio_

Sites is the full website builder (distinct from Web Studio's single landing pages). Generate a complete multi-page site from a prompt, edit pages individually, and publish under your own custom domain.

## Steps
1. Go to Sites (sidebar > Sites).
2. Click "🤖 AI Create New" — describe the site (industry, sections, tone) and pick a type (business / portfolio / store / blog).
3. Wait for the build (runs in a background job; progress streams over Socket.io). A landing page usually takes 2–3 minutes, and a multi-page site about the same because its pages are written at the same time; the bar shows the time left. When done, the editor opens and the site appears in your Sites list. If CRMown AI cannot finish (or nothing has come back after 10 minutes) you see an error instead of a spinner, and nothing half-built is left behind.
4. Click "Edit" on any site to open the multi-page editor — add/rename pages, edit HTML/CSS, set per-page SEO + sitemap settings.
5. Publish — files render at /s/{slug} or your connected custom domain. Sitemap.xml auto-builds across all published pages + blog posts.
6. Change a page in plain English: just tell the CRMown AI bar (Ctrl/Cmd+K) what to change — "change the headline on the Home page of acme.com to X" — and it makes the change itself after you confirm (it asks which site or page if that's unclear). Inside the editor, the AI Assistant panel does the same for the page you have open. Both run the same AI rewrite of that one page in the background. Adding something new works on pages of any size: "add a registration form section below the hero", "put an FAQ above the footer" — on a large page CRMown AI writes just the new section in the page's own colours and fonts and slots it in where you asked (or above the footer), leaving the rest of the page untouched. A form added this way sends its entries to Forms > Submissions and creates the contact, with no extra setup. It saves straight to the page, like saving in the editor — a draft site stays a draft until you Publish, and a published site shows the change once it's done (sites delivered from a published CDN copy update when you Publish). A copy of the previous version is kept.

## Tips
- Sites differ from Web Studio funnels: Sites = multi-page brochure/marketing/blog, Web Studio = single landing pages, opt-in pages, and funnels.
- Site assets are stored in your connected file storage provider (R2 by default).
- Custom domain: connect via Settings > Communications > File Storage workflow (or via the Sites detail page once built).
- AI Site generation makes ONE AI call per page — by design, so each page gets a focused, full-quality response. Defaults: type "website" → 4 pages (Home, About, Services, Contact) = 4 calls; type "funnel" → 3 pages = 3 calls; type "landing" → 1 page = 1 call. So one site build typically shows up as multiple "Site Generation" rows in Settings > AI Usage — that is the same task, not a duplicate run. To minimise tokens for a quick test, use the "landing" type.
- Multi-page WordPress (or any site with a sitemap) migration: on Sites > AI Create New click "📥 Import Existing Site", paste the homepage URL, then click "🗺 Discover All Pages". We probe /sitemap.xml, /sitemap_index.xml, /wp-sitemap.xml (WP 5.5+ native), and robots.txt. Top 20 pages are pre-checked; toggle the rest. Three modes: "📋 Static" for plain WordPress (fastest, free) — direct fetch, images auto-rehosted to your storage; "🌐 Render JS" for JS-heavy themes (Elementor, Divi, React/Next, headless WP) — same as Static but uses headless Chromium so JS-rendered content is captured (free, slower); "🤖 AI Rebuild" — fetches every selected page, asks 5–6 clarifying questions about your business, then rewrites each page with CRMown AI using your answers as context (cost: ~N+1 AI calls — 1 shared header/footer + N page rewrites — uses tokens from your monthly cap or BYOK key). Up to 30 pages per import, 3 fetched in parallel for direct/render, 2 in parallel for AI rebuild. If individual pages fail (HTTP error, timeout, etc.) they're reported on the success screen so you can retry them as single-page imports.
- ZIP upload (hand-built static sites): on Sites > AI Create New > Import, choose Upload ZIP of HTML files. Each .html file becomes a page; images, CSS, JS and fonts go to your storage. Limits: 50MB and 500 pages and assets. Hidden files (.DS_Store, ._ files, __MACOSX) and file types the import doesn't use don't count toward the 500. If a site is bigger, remove unused images or split it into two ZIPs.
- WordPress export (.xml/.wxr) upload: for closed/firewalled WP sites the URL won't reach. From wp-admin go Tools > Export > All content > Download Export File, then on Sites > AI Create New > Import scroll to "Upload WordPress Export" and pick the file. Up to 50MB. We parse it server-side, strip nav menus / attachments / revisions / WP-internal post types, then show a checklist of pages and posts. Default selection is published pages only; toggle the type filter to add posts, drafts, etc. Common shortcodes (gallery, contact-form-7, wpforms, captions) are stripped — plugin-driven content like forms or e-commerce won't carry over (re-add via CRMown Forms after import). "Rehost images & media" toggle (default on) walks each page's HTML for absolute http(s) image/PDF URLs and pulls them into your BYOS so the site keeps working when the source WP goes down. Up to 100 items per import.
- Re-pull from source: any Site that was created via an import flow (single-URL, sitemap, AI rebuild) shows a "↻ Re-pull" button next to Save / Publish in the editor. It re-runs the original import and REPLACES every page atomically — your editor changes will be lost, so the confirmation dialog is loud about this. AI-rebuild Sites re-pull as direct mode (the original Q&A answers aren't kept), so the result will be a 1:1 of the current source. WXR-imported Sites can't re-pull because the source file isn't kept on the server — re-upload the WXR file to import again.
- Asset rehosting (images, video, audio, documents): every import path walks the imported HTML for absolute http(s) URLs and pulls them into your BYOS / R2 / S3 — so the imported site keeps working when the source goes offline. Coverage: img src/srcset, picture sources, video src/poster, audio src, lazy-load attributes (data-src, data-srcset, data-lazy-src, data-original, data-bg, data-orig-file, data-medium-file, data-large-file — most WP lazy-load plugins), <link rel=preload>, ALL CSS url() references (background-image, mask-image, border-image, list-style-image, cursor, content) inside <style> blocks AND inline style attributes, AND downloadable documents linked via <a href>, <embed>, <object>, <iframe> when the URL ends in .pdf, .doc, .docx, .xls, .xlsx, .ppt, .pptx, .csv, or .zip (menus, whitepapers, brochures). Multi-page imports share a per-job cache so a logo on every page rehosts ONCE, not N times. Per-import cap of 200 unique assets; extras stay as hotlinks and the success screen tells you how many were skipped. Per-asset size caps: 8MB images, 25MB documents, 50MB video/audio. HEAD-first preflight rejects oversized files without downloading them. Single retry with 750ms backoff on transient 5xx/429/network errors so a flaky source doesn't leave assets hotlinked. Concurrency capped at 5 simultaneous fetches to avoid hammering the source.

## Example
A new home-services business types: "5-page site for an Austin landscaping company — Home, Services (mowing/install/seasonal), Gallery, Reviews, Contact". 90 seconds later they have a complete, brand-coloured site live at /s/austin-landscaping. They edit page copy and add their logo, then connect "austinlandscaping.com" as a custom domain over the weekend.

## Troubleshooting
- **Published site shows "Not Found"** — Site not published, custom-domain DNS not pointed correctly, or the page slug is wrong. Fix: Web Studio > Sites > click your site > click Publish. For custom domains, verify DNS records point to CRMown (CNAME to the provided target). Check Settings > Domains.
- **Custom JavaScript not working on published pages** — Script tags can be stripped during save (known editor state issue). Fix: Use the Custom JavaScript field in the page's Settings tab — scripts entered there are injected at publish. Alternatively paste scripts directly in the HTML Code view.
- **Generating a page with AI is still running after a couple of minutes** — Each page is one long CRMown AI call that writes the whole page, and that usually takes 2–3 minutes. It is not stuck while the bar moves. Fix: Leave the page open; the editor opens by itself when the page is ready. If CRMown AI cannot finish, you get an error (after 10 minutes at most) and can simply try again.
- **One AI site build shows up as 3-4 "Site Generation" entries in Settings > AI Usage** — Not a duplicate run — the AI generator makes one call per page so each page gets dedicated context and stays under the per-call token cap. Type "website" = 4 pages = 4 calls; "funnel" = 3; "landing" = 1. Fix: Expected behaviour. To reduce token spend for testing, generate with type "landing" (1 page, 1 call). For a full multi-page site, the per-page cost is the trade-off for higher-quality, focused HTML on each page.

## Error messages
- `Domain already in use` — The custom domain is connected to another site. Remove it from the other site first.
- `SSL certificate pending` — DNS was just updated. SSL certificates take 5–15 minutes to issue. Wait and refresh.
- `Publish failed` — Server error during site generation. Try publishing again. If persistent, confirm all pages have valid content.
- `The page is too large for a full AI rewrite — try a smaller change or edit a section. … You can still ask CRMown AI to add a new section.` — A change that reaches across the whole page (restyle, translate, change every heading) has to return the whole page, and this page is too big to come back complete. Nothing on the page was changed. Adding a new section still works on any page ("add a sign-up form below the hero"); otherwise ask for a smaller change or edit that section by hand.
- `The AI rewrite dropped a large part of the page, so it was not saved` — The rewrite came back much shorter than the page although you didn't ask to remove anything, so it was discarded. Nothing on the page was changed. Try a smaller, more specific request.
