Documentation › How it works
Detection and schema inference
How Galley works out a site's framework, commands, collections, fields, page sections, URLs and media without running any of its code — and the precedence config > schema > inferred.
This page is for developers. It explains the first principle — zero config, then config — by walking through what detection reads, in order. galley doctor prints the result; GET /api/sites/<id> returns it as the SiteModel.
Nothing is executed: no config file is imported, no dev server is started, no package script is run. Everything below comes from reading files.
Link to this section: 1. The framework
Each built-in adapter rates how well it matches the folder — from the packages in package.json and the config files present — and the most confident wins. The built-in adapters, in the order that breaks ties:
| Id | Recognised by | Collections come from |
|---|---|---|
astro | the astro package, astro.config.* | src/content.config.*, read statically — see Astro |
docusaurus, nuxt, next, sveltekit, eleventy, hugo, jekyll | their packages and config files | conventional content folders, scanned |
generic | anything | any folder holding two or more markdown files with front matter |
Only Astro has an adapter that reads the framework's own configuration; the others know how to run the site and where its content conventionally lives. "framework" in galley.config.json overrides the choice. Adapters for other frameworks are on the roadmap; see Adapters.
Link to this section: 2. Commands and package manager
- Package manager: from the lockfile —
pnpm-lock.yaml,yarn.lock,bun.lock/bun.lockb, else npm. - Dev command: the first of the
dev,startorservescripts inpackage.json, run with that package manager (npm run dev). Its port comes from a--portin the script, else the framework's default (4321 for Astro). - Build command: the
buildscript; output folder from the framework (distfor Astro).
Link to this section: 3. Collections
A collection is either a folder of entries (one file per page or post) or a single data file (settings, navigation). The framework's adapter declares them when it can; otherwise folders are scanned. Data files under the framework's data folders — src/data/*.{json,yaml,yml} on Astro — become data collections.
Link to this section: 4. Fields
Each collection's fields come from two sources, joined:
- The schema, when the framework declares one — on Astro, the zod schema in the content config, read as far as it is plainly readable. Schema fields are marked
source: "schema". - The files themselves. Up to 400 files per collection are read and every value is classified (
content/schema/infer.ts). Inferred fields are markedsource: "inferred".
What inference looks for:
| Evidence in the files | Field type |
|---|---|
true/false everywhere | boolean |
| numbers everywhere | number |
2026-11-20 / 2026-11-20T09:30 | date / datetime |
| a path or URL ending in an image extension | image |
https://…, mailto:, /a/path, #anchor | url |
#1f6feb | color |
| several lines, or markdown syntax | text / markdown |
| a list of short strings | tags, with the values seen as suggestions |
| a list of objects that share a type key | blocks (page sections) — see below |
| a nested object | object, with its own fields |
| a number here, a string there | string — Galley doesn't guess between them |
A field present in 95 % or more of the files is required. A string field becomes a select only on strong evidence: at least 12 files and no more than 8 distinct values, each 40 characters or shorter — otherwise it stays text, and you can add options in config. Up to three real values are kept as examples: placeholders in the form, and context for the assistant.
Link to this section: 5. Page sections (blocks)
A list of objects that all carry one of these keys — type, _component, _type, block, component, template, _template, blockType, _block — on at least 90 % of the items becomes a blocks field. Each distinct value is a block type with its own fields, inferred from every instance, and the most complete real instance is kept as its example — the scaffold Galley uses when someone adds a section of that type.
On Astro, a z.discriminatedUnion("type", […]) in the schema declares the block types directly; the files then fill in examples. See Page sections from discriminated unions.
Link to this section: 6. URLs, media and the live site
- URLs: each collection's URL pattern (
/blog/{slug}/) comes from the framework's routes — on Astro, the dynamic routes insrc/pagesthat render that collection. A collection no route renders getsurl: nulland no page of its own, anddoctorsays so. - Media: the public folder (
public/) and, inside it, the first ofimages,img,assets/images,assets/img,assets,media,uploads. New images are saved there; the whole public folder is scanned for the library. - The live address:
sitein the Astro config (a placeholder such asexample.comis ignored), aCNAMEfile, orhomepageinpackage.json. - Assistant instructions:
STYLE.md,STYLEGUIDE.md,STYLE_GUIDE.md,style-guide.md,docs/style-guide.md,brand/voice.md,VOICE.mdorBRAND.md, if present.
Link to this section: Precedence: config > schema > inferred
Three sources can describe the same field. They are layered, never mixed blindly (content/schema/merge.ts, content/config/config.ts):
- Inferred is the base: what the files show.
- Schema is authoritative about which fields exist, their types and what is required. The files may only refine a vague declaration: a
z.string()that every file fills with an image path becomes animagefield; a list of objects whose items all carry a type key becomesblocks. A field the schema couldn't read statically (json) takes the inferred definition. - Config (
galley.config.json) beats both. It merges by collectionidand fieldkey, so one line can fix one label without restating anything else. A field getssource: "config"once config touches it.
Link to this section: When detection is wrong
Run galley doctor and read its notes — they say what was read, what was ignored and why. Then correct it in galley.config.json (Configuration): a wrong label, a field that should be a select, a collection detection missed (give it a path), a URL pattern. If the content config itself couldn't be read, doctor says which part, and the collections fall back to the folders under src/content/.
Link to this section: Next
- What Galley reads from an Astro project.
- Collections and fields — every override.
- Field types.