What Is a Slug and How Does It Affect Your URL?

Of all the odd lingo that you hear when learning about website building, “slug” is definitely one of the stranger ones.

What is a website slug? In this context, it’s not an animal — it’s the piece of a URL that identifies the specific website page you’re on.

Whenever you see the name of a post, page, category, or tag tacked on to the end of a website address, that’s the slug. It helps create a specific URL, also known as a “permalink,” that people use to access the exact page on your website they want to visit.

While WordPress.com slugs are used for posts, pages, categories, or tags, most people only worry about how they affect pages and posts. This article will focus on how the slugs for your posts and pages are generated and why they matter.

A quick history of slugs

In the days before website building services like WordPress.com existed, web developers needed to create pages of code written in a coding language called HTML. Each page of your website would need its own HTML file.

So, if you wanted an About Me page on your site, you needed a separate file for it called: “about.html.” Once that page was published, its URL would read as the site’s domain (www.example.com) followed by a slash (/) and then the HTML file’s name (e.g. www.example.com/about.html).

Services like WordPress.com don’t use HTML files like this, but the browser still needs to know which page to display. Today, the name of an HTML file is replaced by the slug. If you create a page with the slug “about,” the URL for that page will be www.example.com/about.

How a slug is generated

By default, WordPress.com uses the title of a page or post to generate its slug. WordPress.com also makes sure that a slug is browser-and search-engine-friendly.

For example, if your title is a single word (e.g. “About”), the slug will be the same word, but in lowercase (“about”).

Where the slug appears on WordPress.com

If you have a longer title, WordPress.com adds hyphens to the slug, as spaces are not browser-friendly. So, the slug for a page titled “My New Page” will become “my-new-page.” Any other non-browser-friendly characters (like currency or special symbols) will either be replaced or removed.

What’s the difference between a slug and a permalink?

WordPress.com tacks the slug onto the end of your website address to generate the final permalink for that page or post, so the slug is the final piece of the entire permalink.

For pages, the permalink will be your domain name followed by the page slug (e.g. https://wordpress.com/about/). The permalinks for posts, however, may also include the date of the post (e.g. https://wordpress.com/discover-wordpress/2018/04/19/website-building-tips/).

This means that you can have a post that uses the same title (and therefore the same slug) as a page, but the permalink for each will be unique.

Are URLs and permalinks the same thing?

Not exactly. All permalinks are URLs, but not all URLs are permalinks. A permalink is a specific type of URL that is a “permanent” link, meant to stay the same over long periods of time. For most purposes, however, the two terms are often used interchangeably.

Why are slugs important for SEO?

A good slug can help both users and search engines understand the page’s topic. For example, if your page is discussing a “fried green tomatoes recipe”, the page slug “fried-green-tomatoes-recipe” would make the page’s topic clear to everyone. Search engines would be better able to determine if this page should be included in the search results when users are looking for this recipe. And if users were to see this printed in a URL somewhere, they would be more likely to feel confident in clicking that link. They might be less confident seeing a slug with a random string of numbers and letters.

Tips for creating SEO-friendly slugs

  • Keep slugs short. As we learned above, WordPress, by default, uses the page or post’s title as the slug. If your title is long, the slug will also be long, and of course, that means the permalink will be even longer. Which is most likely to be preferred by users and search engines?
    • example.com/fried-green-tomatoes-recipe
      or
      example.com/i-made-my-mommas-fried-green-tomatoes-recipe-and-i-promise-you-are-gonna-love-it-and-so-will-your-family
    • The first is easier to read, remember, and understand, so it’s best to edit the default permalink on occasion. You’ll see how to customize the slugs in a moment.
  • Remove stop words when it makes sense to do so. A stop word is a short word like “a”, “the”, “of”, etc. Pronouns, articles, and prepositions are often stopwords. In our example, if the slug is the-best-fried-green-tomatoes-recipe, “the” would be considered a stopword. Removing “the” from the slug would make the slug shorter, and it would not lose any of its meaning. In this situation, removing the stop word is a good decision. However, removing stop words from all slugs may not be a good idea, as stop words sometimes help clarify the meaning of the slug. For example, if your slug is what-are-fried-green-tomatoes, removing the stop word, “are”, would result in an awkward and confusing slug of what-fried-green-tomatoes.
  • Use keywords in your slug. Keywords are the words and phrases that people search for when trying to find content on the web. If someone is looking for a recipe to make fried green tomatoes, they will likely use some form of “fried green tomatoes recipe” as their search term. Likewise, you’ll want to use an often used keyword phrase in your slug. Instead of a slug like yummy-delicious-and-oh-so-southern, you’ll be wise to use something more like fried-green-tomatoes-recipe instead.

Customizing your slugs

For both posts and pages, you can edit the slug by selecting More Options from the menu to the right of your editor.

More options for changing your slug

For pages, the slug will also appear in an auto-generated permalink just below the title (see the image under “How a slug is generated”). By selecting the slug portion of the permalink, you can enter your own custom slug for that page.

Creating custom slugs is a great idea if your post or page title is especially long, or if its permalink would be difficult to remember. Having a good slug can also help you rank higher in search engine results, as Moz explains.

Now that you’ve answered the question, “What is a slug?”, make sure that your own slugs are all serving your site well.

ABOUT THE AUTHOR

Jonathan Bossenger

Developer educator from Cape Town, South Africa with a passion for open-source software.

More by Jonathan Bossenger