Skip to content


slug adds a text field to the schema that is restricted to producing strings strings acceptable as Apostrophe document slugs. All docs already have a slug with with the name "slug," as required by Apostrophe. It is therefore rare that developers have need to create additional fields of this type, but it is allowed.

Text entered in a slug field is immediately lower-cased and all spaces and punctuation are replaced by dashes (-).

Module field definition

// Configuring the `secondSlug` field in a module's `fields.add` subsection:
projectSlug: {
  label: 'Enter a unique identifier for the project',
  type: 'slug'



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


autocompleteStringn/aSets the value of the autocomplete attribute on the field.
defStringn/aThe default value for the field
followingString/Arrayn/aThe name of a field or an array of field names that will be used to automatically generate this field's value. If this field is edited to no longer match the fields it is following, it will stop responding to edits in those fields.
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
pageBooleanfalseIf true, then slashes are allowed since the slug field is describing a page doc
requiredBooleanfalseIf true, the field is mandatory
readOnlyBooleanfalseIf true, prevents the user from editing the field value


The string supplied to the autocomplete option is used as the value of the autocomplete attribute for the field, as specified in the HTML standards. This feature suggests possible values based on user inputs and previously entered data, streamlining data entry and improving form usability. This also takes a string of off to disable autocomplete for sensitive fields. For detailed information on how the autocomplete attribute works and the values it accepts, refer to the MDN documentation on autocomplete.


If you are overriding a piece type or page type's slug field and that doc type uses a slug prefix, the slug field should include 'archived' in the following option. It is used by the slug field type to manage prefixes, though its value is not included in the slug name.

slug: {
  type: 'slug',
  label: 'Slug',
  following: [ 'title', 'archived' ],
  required: true

Overriding the slug field is typically only necessary if you want to change the following string fields.

Use in templates

If adding a new field with the slug type, it is most likely not going to be used in templates, but it is allowed as a string value.

{{ data.piece.projectSlug }}