rmariuzzo / slugify

SEO-friendly URLs with Slugify

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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:

<dependency>
	<groupId>com.github.slugify</groupId>
	<artifactId>slugify</artifactId>
	<version>2.1.3</version>
</dependency>

Now you're able to use it:

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

You can set custom replacements for Slugify:

Slugify slg = new Slugify();
slg.setCustomReplacements(new HashMap<String, String>() {{
	put("foo", "bar");
}});

// Result: hello-bar
String s = slg.slugify("Hello foo");

Or if you want case sensitivity:

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

About

SEO-friendly URLs with Slugify

License:Apache License 2.0


Languages

Language:Java 100.0%