Blocks & Layouts
Kirby Copilot supports generating content for Kirby's blocks and layout fields, including both built-in and custom block types, so a prompt can produce a whole page structure instead of one field.
It accomplishes this by using object generation with JSON schemas, which enables the AI model to generate structured data that matches the block definitions in your project.
Luise Frey: Rooms of Silence
Layout ×
excludedBlocks configuration option. This allows you to fine-tune which blocks Copilot should generate content for.How It Works
Copilot considers Kirby's built-in blocks, blocks registered by plugins, and custom blocks defined in site/blueprints/blocks/ – limited to the field's fieldsets when the field sets them. Layout columns take their widths from the field's layouts option. Blocks appear in the Panel as they stream in, and generated content is appended to existing field content, not replaced.
Block Descriptions
Custom block blueprints support an optional description key. Copilot passes this description to the AI model as part of the block's schema, giving it richer context about the block's purpose and expected content.
name: Highlight
description: A visually prominent section showcasing a key metric or achievement, such as "200+ customers" or "99.9% uptime"
icon: chart
fields:
number:
type: text
label:
type: text
description:
type: writer
Without a description, the schema only includes the block's name. Adding one helps the AI model understand the block's intent and generate more fitting content, especially for project-specific blocks where the name alone is ambiguous.
Nested Blocks
Custom block blueprints that contain a type: blocks field – blocks within blocks – are fully supported. If the inner blocks field specifies a fieldsets option, only those allowed block types will be included.
Caveats
Depending on the block's complexity, the resulting JSON schema can become equally complex. This leads to the following caveats:
- Schema size: OpenAI has limitations on the nesting depth and size of JSON schemas. If the schema is too large, the AI model will fail to generate a response. In this case, try reducing the number of blocks used in the
fieldsetsor simplify the block definitions. - Layout generation: layout schemas nest one level deeper than block schemas, so they are the first to hit that limit. The plugin does not restrict the provider – OpenAI models are free to try and will simply fail on schemas they cannot handle. Gemini models are the reliable choice here.