Slug Field Type

Additional attributes, defaults, and usage example for slug fields.

This field should only be used by API CMSs. In general, Netlify Create will inherit the functionality as defined in the CMS's schema.
Control Type
Simple text input with helper text that informs of the resulting slug.
Stored Value
String altered to match the URL-friendly value from the input.

Usage Example

Here is an example that shows a slug field on a page.

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
export default {
  models: {
    Page: {
      fields: [
        { name: 'title', type: 'string', required: true },
        { name: 'slug', type: 'slug', required: true },
      ],
    },
  },
}

This will render a simple text input with helper text pulled from the (interpolated) urlPath attribute for that model.

Slug Text Field Control
Slug Text Field Control

Slug Behavior for Git CMS

When content is stored in files (Git CMS), the slug is the path to the file relative to pagesDir, excluding the file extension.

For example, if a content file is stored at the path content/pages/about.md, and urlPath is left to the default /slug, the page will be mapped to the URL /about .

This behavior cannot be adjusted at this time. It is recommended to use the default slug behavior provided by Netlify Create when storing content in files.

Changing a Slug Value

Typically slugs determine the URL of a page. Because of that, it's generally a dangerous action to change a URL. Netlify Create shows a warning when changing an existing slug value.

Slug Warning Modal
Slug Warning Modal