Generates a human-readable, URL slug from an ordinary string
A slug is commonly used as part of a URL that corresponds to a specific resource or webpage.
Generally, a slug is a very short description of what a specific resource or webpage is about, so it should be very easy to understand, short and to the point.
Slugs are used to contruct user friendly and search engine friendly URLs, they are generally easy to remember and typically they are the headline of a news article, a blog post or an online guide or tutorial.
So, for example, if we take a look at typical blog post on Bonkers About Tech, you'll notice the slug in the URL:
The slug part of the url is the headline of the post and typically, the slug is all in lowercase and the words are separated by hyphens.
To keep the URL to a reasonable length, non essential words are removed and accented characters, punctuation and other special characters are also removed. This also makes it easier for users to type and remember the URL. It also makes the URL more aesthetically pleasing.
So for example, it's much better to have a URL like this:
As opposed to this:
Slugs are very common on the web today and you'll see them on almost every blog.
Not only do slugs help the reader looking at the URL know what a particlar webpage or blog post is about, it also helps search engines to know what your page is about too.
Given that URLs are indexed by the search engines, then it's probably safe to assume that search engines give attention to the URL slugs and what keywords are contained within them.
So here's a few tips to enable you to optimize your slugs to help improve your SEO.
It's a good idea to remove stopwords such as "and", "a", "the" etc because not only do they take up unnecessary extra space within a URL, they don't contribute anything to SEO.
If you're a user of the Yoast SEO plugin then the stop words actually get filtered out by default.
However, having said that it's wise to use a little common sense, because removing certain stop words from your slug can actually make your URL read differently, which could negatively affect your SEO and mislead the user.
is different than:
So if your headline or blog post title is quite long, it probably makes sense to remove stop words, however if your URLs are short, then the URL will actually read better with the stop words included.
In summary, remove all the words that you don't need but don't remove too many in case it conveys a different meaning that wasn't intended.
Shorter URLs are easier to remember but another advantage of using short slugs is that slugs are actually displayed in Google's search results.
So with a good descriptive slug, you can actually entice users to click on your link in the SERPs.