Browse the docs

slug

Makes text safe for a file name or link: lower case, accents folded, dashes between words.

Details #

slug(text, separator?) lower-cases the text, folds accents (é becomes e), and turns every run of anything that is not a letter or digit into one separator, with none at either end. The separator is - unless you give another.

It is also the slug op of Transform text (the separator param).

Parameters #

Takes 1 to 2 arguments. {{ slug(text, b?) }}

Examples #

slug("Café Déjà Vu!")
→ cafe-deja-vu
slug("Q3 report (final).pdf", "_")
→ q3_report_final_pdf

Gotchas #

  • Case boundaries are not word breaks: slug("parseURL") is parseurl. Use kebabCase for that.

  • Letters in other scripts are kept (slug("日本語 test") is 日本語-test).