slugify

by slugify

slugify / slugify

SEO-friendly URLs with Slugify

209 Stars 30 Forks Last release: Not found Apache License 2.0 179 Commits 20 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

Slugify Build Status

SEO-friendly URLs with Slugify

Notice

If you want to use it directly in your JSP, take a look into jstl

Usage

If you want to use Slugify in your Java code you only need the library itself. Here's the dependency information for Maven:

    com.github.slugify
    slugify
    2.4

Now you're able to use it:

Slugify slg = new Slugify();
String result = slg.slugify("Hello, world!");
// result: hello-world

You can set custom replacements for Slugify:

Slugify slg = slg.withCustomReplacement("hello", "world").withCustomReplacement("foo", "bar");
// or multiple at once
slg = slg.withCustomReplacements(new HashMap() {{
    put("hello", "world");
    put("foo", "bar");
}});

String result = slg.slugify("hello foo"); // result: world-bar

Or if you want case sensitivity:

Slugify slg = new Slugify().withLowerCase(false);
String result = slg.slugify("Hello, World!");
// result: Hello-World

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.