Working with the slug field
#Overview
A slug field is a field type used to create parts of a URL that identify a page with a human readable slug, which is both user & search engine friendly. The resulting slugs are concise and contain relevant keywords.
Slug example
Typically, a slug consists of lowercase letters, numbers, and hyphens, with spaces replaced by hyphens or simply removed.
#What you can do
You can configure an initial value for slugs using the slug field type. This field is of type String
in your GraphQL schema but provides a powerful UI feature that comes in the form of automatic initial value generation.
You can configure the slug field to be generated from other field values in your model.
Slug - Adding a slug field
#Create a slug field
- Navigate to the Schema builder and select the model you want to add a slug field to.
- Select
Slug
from the Add field sidebar. - Add a
Display name
, which will autocomplete theAPI ID
. You can optionally add aDescription
. - Under Slug options, specify whether this field should be lowercase, and enable whether you want this field to be generated from a template.
- If you opted to generate from template, enter a template for your slug.
- Configure any additional settings for the model. By default, the field will be set to unique, and a specific matching pattern will be provided.
- Click
Add
to save.
#Slug templates
Each Slug field template can be generated using the Available fields outlined above the input. If your model has a title
, or name
field, you could specify the slug template as {title}
, or {name}
respectively.
#Using the slug field
When creating content, the slug field will be automatically generated from the template field you're using.
For example, if your slug field is based off a title
field, when you start typing into the title
field, it will also update the slug field.
You can override the slug field value by typing in the box. You can also "Regenerate" the value to fallback to the template you provided.