Skip to content

url

url adds an editable URL field to the schema.

Apostrophe will detect common mistakes, including leaving off https://. Common XSS attack vectors are laundered and discarded. Only "safe" URL schemes, e.g., http, https, ftp and mailto, are permitted.

Module field definition

javascript
// Configuring the `portfolio` field in a module's `fields.add` subsection:
portfolio: {
  label: 'Portfolio URL',
  type: 'url'
}

Settings

Required

PropertyTypeDefaultDescription
labelStringn/aSets the visible label for the field in the UI
typeStringn/aSpecifies the field type (string for this type)

Optional

PropertyTypeDefaultDescription
defStringn/aThe default value for the field
helpStringn/aHelp text for the content editor
htmlHelpStringn/aHelp text with support for HTML markup
ifObject{}Conditions to meet before the field is active. See the guide for details.
requiredIfObject{}Conditions to meet before the field is required. See the guide for details.
hiddenBooleanfalseIf true, the field is hidden
requiredBooleanfalseIf true, the field is mandatory
readOnlyBooleanfalseIf true, prevents the user from editing the field value

Use in templates

nunjucks
<href="{{ data.piece.portfolio }}">My website</a>