If you are not familiar with a slug and you hear a web developer refer to a slug, this article will help you clarify what they mean.

What you might think it means

Typically when you think of a slug, you probably imagine those creepy crawling snail-like slugs.

Slug Image

That's not what the developer means when they refer to a slug.

Or, perhaps your mind goes back to your child-hood video game days and it reminds you of that awesome game Metal Slug

Metal Slug Game Image

Although Metal Slug is a badass game, this is not what the developer means either.

What it actually means

When a developer refers to the term slug they are referring to a URL slug.

A URL slug is a URL friendly string.

URL strings are supposed to contain only alpha numeric characters and other characters are reserved or not allowed in a URL. So, when a string is converted to a slug it will typically be stripped of all these unsafe characters.

Often times a slug will be derived from a title. As an example, a webpage titled: How to Make Toast?, might have a slug like: how-to-make-toast. So, the full URL would be something like site.com/how-to-make-toast

Take a look at a few of these examples:

title = 'I Love Waffles';
title_slug = 'i-love-waffles';
title = 'How Do You Make French Toast?';
title_slug = 'how-do-you-make-french-toast';
title = 'Hamburger & Fries';
title_slug = 'hamburger-and-fries';

Pretty straightforward, right? It's as simple as that. When a web developer refers to a slug they are referring to a URL friendly string.

Now, when an entomologist (a person who studies insects) refers to a slug they are probably not referring to a URL friendly string.


or Sign Up

Sign Up

or Login
Cheers Friend!

I'm Tony, the creator of this site. I'm trying to increase my twitter following. Want to follow me?

Follow @tnylea If not, no worries :)