Block
A block holds one of several field groups, and the editor chooses which. With list: true it becomes a page builder: a list of sections that can each be a different kind.
Add this field under fields in .pages.yml:
- name: sections
type: block
list: true
blocks:
- name: hero
label: Hero
fields:
- name: heading
type: string
- name: image
type: image
- name: text
label: Text
fields:
- name: body
type: rich-textEach item stores its fields plus the block's name under _block:
sections:
- _block: hero
heading: Welcome
image: /uploads/hero.jpg
- _block: text
body: Hello worldIf the site expects a different key, such as type, set blockKey:
- name: sections
type: block
list: true
blockKey: type
blocks: …In an Astro content schema, a block list maps well to a discriminated union on that key, such as z.discriminatedUnion('type', [...]).
Keys
blocks and blockKey go directly on the field, not under options.
A saved item must name one of the configured blocks.
Tips
- Define blocks as components to share them between collections:
- { name: hero, component: hero }. - A block's own fields can be lists or objects, such as a list of FAQ items inside an
faqblock. An entry inblocksitself can't taketype,list,requiredoroptions.