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.
So I have shown the three parts of a web page in above image in red boxes.
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,
Page Title: IT solutions & consulting
Complete URL of the Page: https://truebodh.com/it-solutions-consulting/
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,
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://22.214.171.124, 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.
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.
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
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.
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.
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.