Slug is the name given to the specific address of a website, it is like the name of a folder inside your computer, I bring this example from the computer, because the root address of the website is not a slug itself, for example:
C:\Program Files, in this exampleProgram Filesis our slug, but without a separator, now let's see it in a website format:
https://converteonline.com/convert-text-to-slug/, here the snippetconvert-text-to-slugis our slug.
Note that, in the analogy with the computer, we do not mention C: and on the website we do not mention https://converteonline.com, this is because such information is not a slug, the set as a whole forms the url, but a slug is only the snippet that identifies a specific path.
The slug is for search engines, such as Google and Bing, to read your site more easily, and also for users, see an example of a non-friendly URL for a friendly one:
Unfriendly URL | Friendly URL |
---|---|
/converttexttoslug/ | /convert-text-to-slug/ |
Note that reading the url in a slug friendly format is much easier to read. In the example above we used the hyphen as a separator, but it is also possible to use the underscore (or underscore), see another example:
Original text | Slug with Hyphen | Slug with Underline |
---|---|---|
Text in Slug | text-in-slug | text_in_slug |
Text in friendly url | text-in-friendly-url | text_in_friendly_url |
Above you can see that all text is turned to lower case, and accents are removed, this is url rules.