slugify

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2026 License: MIT Imports: 2 Imported by: 0

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

func IsSlug(s string) bool

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

func Make(s string) string

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

func MakeWithSep(s, sep string) string

MakeWithSep is like Make but uses sep as the word separator.

slugify.MakeWithSep("Hello World", "_") // "hello_world"

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL