Overview
Theslugify macro converts any string into a URL-friendly slug by converting to lowercase, removing special characters, and replacing spaces with hyphens.
Syntax
Parameters
The string to convert into a slug format
Return Value
Returns a string formatted as a URL-friendly slug:- Converted to lowercase
- HTML tags stripped
- Spaces replaced with hyphens
- Special characters removed (only alphanumeric, hyphens, and underscores remain)
- Multiple consecutive hyphens collapsed to single hyphen
- Leading and trailing hyphens removed
Usage
Import the Macro
Basic Example
give-me-slug
With Special Characters
hello-world-how-are-you
With HTML Tags
title-with-tags
Common Use Cases
Implementation Details
The macro performs the following transformations in order:- Converts to string and lowercase
- Strips HTML tags
- Replaces whitespace characters (tabs, newlines, spaces) with hyphens
- Removes all non-alphanumeric characters except hyphens and underscores
- Collapses multiple consecutive hyphens into a single hyphen
- Trims hyphens from the beginning and end of the string