# Slug field

Learn how to create a slug field, generate its value from a template on the current model or a related model, and manage it during content entry.

Use a slug field to generate a URL-safe, human-readable identifier for an entry, such as `getting-started` for an entry titled "Getting Started". Configure it to generate the value automatically from a template built from other fields on the model, including fields on a [related model](https://hygraph.com/docs/developer-guides/schema/references).

![Slug example](https://hygraph.com/images/docs/user-guides/slug-example.png)

## Create a slug field

1. Go to the **Schema** builder and select the model you want to add the field to.
2. In the Fields sidebar, click **Next** to **Slug**.
3. Enter a **Display Name**. Hygraph autocompletes the **API ID** from it. Optionally, add a **Description** if you want to hint at the field's purpose to editors.
4. Under **Slug options**, choose options for the slug field:
    - Select **[Generate slug from a template](#generate-slugs-from-a-template)** to auto-populate the slug value from string fields of this model or a related model. Then, enter the [slug template](#generate-slugs-from-a-template).
    - Select **Lowercase** to convert the slug value to lowercase characters.
5. Configure any additional [field options](https://hygraph.com/docs/api-reference/schema/field-configuration#settings), [validations](https://hygraph.com/docs/api-reference/schema/field-configuration#validations), and [advanced settings](https://hygraph.com/docs/api-reference/schema/field-configuration#advanced). By default, the field will be set to unique, and a specific matching pattern will be provided.
5. Click **Add**.

### Generate slugs from a template

A slug template builds the field's value from other string fields on the model or any related model. The **Available fields** list above the template input shows every field you can reference, including fields on a related model.

You can combine more than one field, or mix in static text, by writing them next to each other in the same template. For example, `{category}/{title}` generates a slug like `guides/getting-started`.

**From the same model**

Wrap a field's API ID in curly braces, such as `{title}` or `{name}`. Hygraph fills in that field's current value.

[Video: Generate a slug from the same model](https://eu-central-1-shared-euc1-02.graphassets.com/AvHQ3RDvFSousA8iwElOKz/cmta32vldvz4307w3afs6b2uf)

**From a related model**

Wrap the reference field's API ID and the related field's API ID together, separated by a dot, such as `{category.title}`. Hygraph fills in that field's current value from the related entry.

[Video: Generate a slug from a related model](https://eu-central-1-shared-euc1-02.graphassets.com/AvHQ3RDvFSousA8iwElOKz/cmta32viovd2u08w7nfpw1w98)

## Slug values in a content entry

**In a new content entry**

When you create a new entry, Hygraph generates the slug automatically as you fill in the template's source fields. Override the generated value at any time by typing directly into the **Slug** field. Click **Regenerate** to discard your override and recalculate the value from the template's current field values.

[Video: Slug in a new content entry](https://eu-central-1-shared-euc1-02.graphassets.com/AvHQ3RDvFSousA8iwElOKz/cmta3x6kwxnrh08w74dn2o4yv)

**In a saved content entry**

Hygraph only auto-generates a slug while the entry has never been saved. Once you save an entry for the first time, editing its template source fields, such as the `title`, does not change the slug. If you edit a source field afterward and want the slug to match, update it yourself or click **Regenerate**.

[Video: Slug in a saved content entry](https://eu-central-1-shared-euc1-02.graphassets.com/AvHQ3RDvFSousA8iwElOKz/cmta3x6igxnr708w7c4589duf)

## What's next

- [Field types](https://hygraph.com/docs/api-reference/schema/field-types): See every supported field type and what it stores.
- [Field configuration](https://hygraph.com/docs/api-reference/schema/field-configuration): Configure options, validations, and advanced settings.
