Convert text to clean, URL-safe slugs with Unicode diacritic handling, separator collapsing, and max length enforcement.
dotnet add package Philiprehberger.SlugifyConvert text to clean, URL-safe slugs with Unicode diacritic handling, separator collapsing, and max length enforcement.
dotnet add package Philiprehberger.Slugify
using Philiprehberger.Slugify;
Slug.Generate("Hello, World!"); // "hello-world"
Slug.Generate("Héllo Wörld"); // "hello-world"
Slug.Generate(" Multiple Spaces "); // "multiple-spaces"
Slug.Generate("C# is great!"); // "c-is-great"
Slug.Generate("über cool blog post"); // "uber-cool-blog-post"
var options = new SlugOptions
{
Separator = "_",
Lowercase = false,
MaxLength = 50
};
Slug.Generate("Hello World", options); // "Hello_World"
MaxLength, trimming any trailing separator.Slug| Method | Description |
|---|---|
Generate(string text, SlugOptions? options) | Convert text to a URL slug |
SlugOptions| Property | Default | Description |
|---|---|---|
MaxLength | 200 | Maximum slug length; truncates at a separator boundary |
Separator | "-" | Word separator inserted between tokens |
Lowercase | true | Convert result to lowercase |
dotnet build src/Philiprehberger.Slugify.csproj --configuration Release
If you find this project useful: