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.
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
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.
🤩 Our Amazing Sponsors 👇View WebsiteDigitalOcean offers a simple and reliable cloud hosting solution that enables developers to get their website or application up and running quickly.View WebsiteLaravel News keeps you up to date with everything Laravel. Everything from framework news to new community packages, Laravel tutorials, and more.View WebsiteA Laravel Starter Kit that includes Authentication, User Dashboard, Edit Profile, and a set of UI Components.
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.
Comments (0)