Field Placeholders

Reference Kirby fields in user prompts to provide additional context to the AI model.

Context is key to effective prompting. By providing relevant information about the content you want to generate, you can guide the AI model to produce more accurate and useful results.

Placeholders in User Prompts

A placeholder is a reference to a Kirby field, written as the field name wrapped in curly braces: {field}. When you send a prompt, each placeholder is resolved by replacing it with the actual field value. This allows you to include content from the current model (page, file, or site) as context in your prompt.

If the field value is not a primitive (e.g. a string, number, or boolean), it will be encoded as JSON. AI models are pretty good at understanding structured data, such as JSON.

Insert Placeholder Dropdown since v2.9.0

Instead of typing placeholders manually, you can use the Insert field placeholder button in the prompt dialog toolbar next to the attachment icon. Click the button to open a dropdown menu that lists all available fields from the current model. Selecting a field inserts the placeholder at the current cursor position in the prompt textarea.

Prompt Preview since v3.0.0

Before sending the prompt, expand the Preview section to see placeholders replaced with their actual field values:

Placeholder Workflows

A common use case is generating a meta description from a page's title and main content. If your model has a content field, you can reference it in your prompt:

Summarize this article "{title}" in a meta description (max 155 characters). Include the main benefit and end with a subtle call-to-action. No quotes.

This is the article:
{content}

With View Button

The Copilot Panel view button is the easiest way to generate text for a specific field. Click on the Copilot button in the Panel view header to open the prompt dialog. The user can then select the meta description field from the dropdown menu and enter the prompt above:

With Writer/Textarea Button

If the meta description field is a writer or textarea field, you can also use the Copilot toolbar button in the field toolbar for quick access to the Copilot prompt dialog.

Suppose your page contains a blocks or writer field with the main content and a textarea field for the meta description:

pages/default.yml
fields:
  content:
    label: Content
    type: writer

  metaDescription:
    label: Meta Description
    type: textarea
    buttons:
      - copilot
    # Pre-define the user prompt
    copilot:
      userPrompt: |
        Summarize this article "{title}" in a meta description (max 155 characters). Include the main benefit and end with a subtle call-to-action. No quotes.

        This is the article:
        {content}

In this blueprint example, the only visible button for the textarea field is the Copilot toolbar button. This will suggest the user to use Kirby Copilot for meta description generation:

Textarea field with Copilot toolbar button

When the user clicks the Copilot button, the prompt dialog opens with the predefined prompt already filled in. Once the prompt is submitted, the {content} placeholder is resolved with the actual content of the writer field.

After generation, the meta description field contains the AI-generated text:

With Copilot Section

Placeholders are also available in the Copilot Panel section. You can set up a Copilot section for the meta description field with a predefined user prompt for a smooth workflow.

An example section configuration for a meta description field could look like this:

sections:
  copilot:
    type: copilot
    field: metaDescription
    userPrompt: |
      Summarize this article "{title}" in a meta description (max 155 characters). Include the main benefit and end with a subtle call-to-action. No quotes.

      This is the article:
      {content}