slug

Converts a string to a URL-friendly slug.

It lowercases the text, drops anything that is not an ASCII letter, digit, or dot, and joins the remaining words with single hyphens. A dot is preserved only when it sits between two digits, so version numbers like "4.5" survive while sentence punctuation does not. Note that non-ASCII letters (accented or non-Latin, e.g. "é" or "日") are removed rather than transliterated, so use it on text that is already mostly ASCII.

InputArgumentsReturnsstringno argumentsstring
Source

Behaviors

Coerces scalars to text
A scalar value such as a number or a boolean is converted to its text form before matching, so 42 is accepted as "42".
BasicSource

Converts free text into a URL-friendly slug.

Given

{"title": "Hello, World! Version 4.5"}

Template

{{ title | slug }}

Result

hello-world-version-4.5
Collapses spacesSource

Collapses runs of spaces and punctuation into single hyphens.

Given

{"title": "  Draft --- Notes & Ideas  "}

Template

{{ title | slug }}

Result

draft-notes-ideas
UnicodeSource

Drops non-ASCII letters rather than transliterating them.

Given

{"title": "Café Münchën"}

Template

{{ title | slug }}

Result

caf-m-nch-n
Version dotsSource

Keeps dots between digits so version numbers survive.

Given

{"title": "Version 1.2.3 Release"}

Template

{{ title | slug }}

Result

version-1.2.3-release