Part of the Twig ecosystem · 43 projects
This module provides a Twig filter that converts text into a URL-friendly "slug" format. You can use it to automatically generate slugs from text fields or strings within your Twig templates, with options to customize the separator and casing.
Implements the cocur/slugify class as a Twig filter for Drupal.
This work carries forward the work in the sandbox here, made compatible for Drupal 9 and 10+.
Usage
After enabling the module you can use the filter in a Twig template on any text field or string value.
Example, on a node with a field_foo value of "This is an Example"
{{ node.field_foo.value|slugify }}
Would render "this-is-an-example".
The filter supports most of the options that the cocur/slugify library supports. For example, disabling the forcing of lowercase and changing the seperator to ***, pass an options object:
{{ node.field_foo.value|slugify({'lowercase': false, "separator": "***"}) }}
Would render "This***is***an***Example".
Ask your assistant about Twig Slugify Filter
Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works
Depends on
Dependencies of the latest stable release
No dependencies recorded for this project.
Required by
Tracked projects that depend on this one
No tracked projects depend on this one yet.
More in the Twig ecosystem
Most installed first