Documentation
¶
Overview ¶
Package slugify converts strings into URL-friendly slugs.
A slug is a lowercase, hyphen-separated string suitable for use in URLs, filenames, or identifiers. Non-alphanumeric characters are replaced with a separator and consecutive separators are collapsed.
Basic usage:
slug := slugify.Make("Hello, World! 2026")
// slug == "hello-world-2026"
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsSlug ¶
IsSlug reports whether s is already a valid slug: only lowercase ASCII letters, digits, and hyphens, with no leading or trailing hyphens.
slugify.IsSlug("hello-world") // true
slugify.IsSlug("Hello World") // false
func Make ¶
Make converts s into a URL-friendly slug using hyphens as separators. It lowercases the input, replaces non-alphanumeric characters with hyphens, and collapses consecutive hyphens into one.
slugify.Make("Hello, World!") // "hello-world"
slugify.Make(" foo bar ") // "foo-bar"
func MakeWithSep ¶
MakeWithSep is like Make but uses sep as the word separator.
slugify.MakeWithSep("Hello World", "_") // "hello_world"
Types ¶
This section is empty.