What is Slug in WordPress
When we write a post in WordPress, first we write a title. Your title may be: My First Awesome Post. When you finished writting you must specify an URL for your awesome post. Otherwise no one can see your post on the Internet. So what should be your URL? Should it be something like the following?
www.mydomain.com/myfirstawesomepost
or
www.mydomain.com/MyFirstAwesomePost
The above format is just not very readable for humans and search engines as well. The slug comes to the rescue! First, slug will make all your letters lowercases. Then it separates your words in the title with dashes or hyphens. Punctuation marks will be removed. So your URL should be something like this:
www.mydomain.com/my-first-awesome-post
Now it becomes much more readable for human eyes.
A slug is part of a URL, the last part to be exact. In the above example, the slug is my-first-awesome-post. It’s not the entire URL. If your URL structure is like this:
www.mydomain.com/blog/my-first-awesome-post
Then the slug is still my-first-awesome-post. Because slug is a few words that describe your post or page.
When an URL is in this format, we say it’s a slug URL.
In WordPress, slug is generated automatically from a post title or page title but you can change it to suit your SEO needs. If you title is too long, you would likely want to change the slug to keep your URL short and hence make it easier for search engines to crawl your web pages. It is usually a good practice not to change the slug after publishing your post or page.
One Interesting thing to note is that After WordPress generates a slug for your post or page, it will be the same even if you change the title. You have to manually change it if it needs to be changed.
Additional Reading: WordPress Glossary: Slug