Contact for queries :

Login

SLUG the Understanding

Slug!! The buzz word SLUG, if you heard, read about this word in context of web page URL and confused what is it! Then you have come to right place. In this article we will understand what this SLUG actually IS?

So every time when we visit a web page we know there is a URL shown in the address bar. See the image below.

Parts of URL and SLUG in a web page
Parts of URL and SLUG in a web page

So I have shown the three parts of a web page in above image in red boxes.

  1. Address Bar
  2. Page Title
  3. Page Content

Now in web browser’s address bar there is a page url address. In our context it is https://truebodh.com/it-solutions-consulting/. The page title is IT solutions & consulting. And rest in the page below is the content of page that has no major concerned as far as our article is about for. So again to make it clear these are the parts we are concerned with,

  1. Page Title: IT solutions & consulting
  2. Complete URL of the Page: https://truebodh.com/it-solutions-consulting/
  3. and this is, yeah, our SLUG: it-solutions-consulting

These type of format of URLs known as by many names like pretty-permalink, beautiful permalinks/url, SEO-Friendly URLs, Canonical URLs etc. These all words are same and related to same subject. They all are made by adding slug part following to main domain name.

So what? Why do we need?

You see many times on internet there are some gibberish name and value query string added to domain. Like this,

https://www.google.com/search?q=what+is+slug&oq=what+is+slug&aqs=chrome..69i57j0l7.2002j0j15&sourceid=chrome&ie=UTF-8

There are many complex values attached in the URL, could you memorize this. What if all websites used these type of URLs for all their pages. Let’s get back some more in history. In earlier days of World Wide Web also works like that. Computers crunch on numbers internally, we know, and in those days websites’ URLs too like in numbers that we calls them IP Address. That is like in this format, http://216.58.214.14 , click on this IP Address URLs and see the magic which page you reached. Bingo!! It’s THE Google search page address.

But as in those early history of internet the problem arises of difficulty in memorizing so many of the sites programmers add some extra layer of coding make a system that a website can have human readable string/text like address and insert them in address bar. Computers automatically convert them in IP address and works in background. This is also true till this date.

So this NUMBER to TEXT conversion concept is again applied we reach to next level of this. Now can remember the domain name but as the dynamic web pages come the values in urls also started to be attached.

This is where again the history repeats and programmers made various tools for normal user to see some PRETTY URLs. And that is what our BUZZ word SLUG. Now all these query strings are converted like a human readable text strings.

Something More about slug.

There are some more to get clear understanding about slug part of URL.

  • It is not necessary or possible as well to make slug in turn pretty permalink everywhere. Sometimes programmers have to depend on query strings also.
  • Even though slug is created, it’s real programmed URLs also work. As if you click on the IP address of Google given above in the article.
  • By using slug in turn pretty permalinks, a website is get better attention by search engine crawlers. So from SEO point of view it is, nowadays, a need for every website owner.
  • No two pages in a (same) website can have same ‘slug’. Just like in a classroom two students can have name but some kinda roll number/registration no. is assigned to uniquely identified a student. Slug is also unique for a page in same website (like same school/classroom).
  • Although I have written this article using WordPress CMS images, but the concept of slug is applied on everywhere no matter what technology or cms or framework is used to create a webpage.
  • Slugs are always sanitized text, that mean no special characters are used to avoid problem in URL rules.

Let’s take an example of wordpress

This is how you type a title and, by default, WordPress automatically make slug using title text. So this is an example before publishing a sample post titled with Don’t Worry!! Be :-) Happy. The real numbered and query string format URLs is http://localhost/mylocal/wptest/?p=20. I have zoomed in the URL section. See below.

Default url with query string
Default url with query string

So this was the real intricate details of URL of this post/page. But see what happens when I published this post/page. The URL becomes automatically a pretty permalink. And guess what is the slug of this sample post will be.

Published content of post
Published content of post

So now if you can not see easily the URL of the page is http://localhost/mylocal/wptest/dont-worry-be-happy/. If we break it in parts then

  1. Page Title: Don’t Worry!! Be :-) Happy
  2. Complete URL: http://localhost/mylocal/wptest/dont-worry-be-happy/
  3. SLUG: dont-worry-be-happy

So now you can see the difference between Title, URL and the BUZZ word the SLUG. If you notice the slug part it removes apostrophe sign (!!), exclamation sign (!!), smiley [ :-) ]. So the whatever the CMS or tools you are using it automatically serve you a complete and correct formatted slug.

Now one more thing, what if I create another post with same title what will WordPress do. Let’s see.

Same Title But Different Slug
Same Title But Different Slug

This is another post with same title, but wordpress already give it’s internal number to save it in database. The internal URL is, http://localhost/mylocal/wptest/?p=22 , But let’s see what happend after publishing the post with same title.

Same title but another post with new Unique SLUG
Same title but another post with new Unique SLUG

You can see having same title of two posts but the slug is automatically produced adding a number. Of Course user can always give his own specific slug to a page. In WordPress see above image in ‘Permalink Section’ you can type your own slug page, if mistakenly you typed spaces or any special character, don’t worry, just click on ‘Publish/Update’ button and leave the rest of work to do for WordPress.

So this is what a SLUG hope you enjoy the article and now you can have adequate understanding what, how, why regarding SLUG.

0 responses on "SLUG the Understanding"

Leave a Message

Your email address will not be published. Required fields are marked *

TrueBodh Technologies Pvt. Ltd.
TrueBodh Technologies Pvt. Ltd.

About Truebodh Technologies

We provide IT Services in Software Development, Web Applications, Mobile Apps, Cloud Services & Solutions to end to end business design.

We provide online learning platform that helps anyone learn software, technology and creative skills to achieve personal and professional goals.We help individual learners achieve personal and professional goals, we offer flexible, cost-effective price. We provide online and offline courses.

Course Progress

top
X