Skip to content

URL slug: what it is, which characters to use and how to write one

Author: Matteo Pellegrini

A slug is the last readable segment of a URL path, the one that identifies a single page: in https://www.visilay.com/blog/url-slug/ the slug is url-slug.

It is written in lower case, with words separated by hyphens, without accents or punctuation and without the filler words from the title. In WordPress you will find it in the Permalink field in the editor sidebar, and you should settle it before publishing: changing it afterwards costs a redirect and a bit of patience.

The three terms get mixed up a lot, including in client briefs. The technical terminology comes from RFC 3986, the 2005 IETF specification by Tim Berners-Lee, Roy Fielding and Larry Masinter that defines URI syntax.

  • The path is everything after the domain: /blog/url-slug/. It can have several segments separated by slashes.
  • The slug is a single segment of the path, usually the last one, which tells this page apart from others at the same level: url-slug. Technically blog is also a slug, the one for the archive that contains the page.
  • The permalink is the full, stable URL of the resource, domain included. It is the end result, not a part of it.

The distinction matters when you discuss URL structure: changing the folder structure and changing one page's slug carry very different risks. The first affects the whole site, the second one line.

Which characters you can actually use

RFC 3986, section 2.3, lists the unreserved characters, the ones that can appear in a URI as they are: unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~". Letters, digits, hyphen, full stop, underscore and tilde. Everything else has to be percent-encoded or is a delimiter with its own meaning.

On top of that technical constraint sit Google Search Central's guidelines on URL structure, which come down to three concrete points: use hyphens rather than underscores to separate words, prefer readable words to long numeric IDs, and percent-encode characters outside the ASCII range. The same page points out that /APPLE and /apple are two different URLs for Google.

CharacterAllowed in the URL?What happens if you use it
lower-case letters a-zyesthe normal case, no side effects
digits 0-9yesno technical problem, but a date in the slug goes stale
hyphen -yesGoogle reads it as a word separator
underscore _yes, buttechnically valid, but Google recommends hyphens: underscores join words together
full stop .yes, butvalid, but a trailing .zip or .php makes the page look like a file
tilde ~yes, butvalid and almost never used: on old servers it marked a user's home directory
capital lettersyes, buttwo slugs that differ only in case are two different pages
spacenobecomes %20 and makes the URL unreadable when copied
accented letters é è ü ñnopercent-encoded: é becomes %C3%A9, six characters instead of one
apostrophe 'nobecomes %27
? # & =nothese are delimiters: they split the URL into query string and fragment

Apostrophes and accents: easy to miss in English

English titles look ASCII-safe, so this problem tends to slip through. It does not take much: contractions ("what's", "don't"), possessives ("a beginner's guide"), loanwords (café, résumé, naïve), brand and place names, and anything pasted in from another language. If the slug is generated from the title without a filter, the browser shows it cleanly, but the real value of the resource contains percent-encoded sequences. On multilingual sites, where French, German or Italian titles sit next to English ones, it happens all the time.

The encoding is not arbitrary: each non-ASCII character is first converted into its UTF-8 bytes, then each byte becomes a % followed by two hexadecimal digits. In UTF-8, é takes two bytes, so it becomes %C3%A9. An apostrophe is a single ASCII byte, so don't becomes don%27t. A slug like resume-template stays at 15 characters; résumé-template grows to 25 in the form that travels over the network.

There are three practical consequences. A URL copied into an email or a message arrives in its encoded, unreadable form. Logs and Search Console reports show the percent-encoded version, so finding a page by name takes longer. And some systems that handle URLs by hand, from feed CSVs to old email clients, cut them off at the first character they do not recognise.

WordPress users start with an advantage. A slug generated from the title goes through sanitize_title_with_dashes(), which lower-cases everything, replaces spaces with hyphens and limits the output to alphanumeric characters, underscores and hyphens; before that, remove_accents(), available since version 1.2.1, converts accented letters to ASCII. So the problem usually comes from a slug typed in by hand or from a migration that imported permalinks from another CMS. If in doubt, open the page and look at the address bar after a reload: if you see % signs, the slug needs rewriting.

How to write a decent slug

The method never changes: take the title, remove the filler words (articles, prepositions, conjunctions) and keep the two or three terms a reader would use to search for that page. That is one of the things keyword research is for: knowing which pair of words is left once you throw everything else away.

Page titleSlug to avoidBetter slugWhy
Why page speed matters for an e-commerce site/why-page-speed-matters-for-an-e-commerce-site/page-speed-ecommercefiller words take up half the slug and do not distinguish the page from any other
2024 guide to keyword research/2024-guide-keyword-research/keyword-researchthe year goes stale in January, and updating it means a redirect
About us/?page_id=1287/about-usGoogle recommends readable words instead of long numeric IDs
How much does a 6 kW solar panel system cost/how-much-does-a-6-kw-solar-panel-system-cost-complete-updated-guide/6-kw-solar-panel-system-cost68 characters against 29, and "complete updated guide" adds no information
Product category: label printers/product-category/label-printers-2/label-printersthe CMS's technical prefix and the numeric anti-collision suffix mean nothing to anyone
SEO services for B2B companies/SEO_Services_B2B/b2b-seo-servicescapitals and underscores: the first creates a separate URL, the second joins the words together

A rule that works well on sites with lots of pages: the slug should stay true even if the title changes. A title gets rewritten ten times in three years; the slug should outlive all ten. That is why it should carry the concept, not the sales pitch of the moment.

How long can it be?

Google does not publish a character limit for slugs, and the specification does not set one. The real limits come from CMSs, and they are far higher than you need.

  • WordPress: the post_name column in the wp_posts table is a varchar(200), so 200 characters (Database Description).
  • Squarespace: 3 to 250 characters for pages, 3 to 200 for blog posts, events and products, with no special characters allowed other than the hyphen (Squarespace documentation).

On the projects we manage, good slugs almost always fall between 15 and 40 characters, two to four words. Not because there is a magic threshold, but because beyond that length you are repeating in the slug what you have already said in the title and the H1, and repetition adds no signal. The same Google Search Central page recommends shortening URLs by removing anything that does not change the content: a slug padded with filler words falls into that category.

Slugs on a multilingual site

On a site with several languages, the slug should be translated, not left in the original language under the foreign language prefix. A URL like /en/blog/costo-impianto-fotovoltaico/ is an English URL with an Italian label: it means nothing to English readers and, for the search engine, contains none of the words people will use to find the page.

Translation plugins such as WPML and Polylang handle one slug per language, but when you create a translation the default value is a copy of the original: if nobody rewrites it, it stays. The same applies to category and archive slugs, which are the part people forget most often. On the Macropix project, rewriting the translated slugs was one of the first jobs, done before touching the content.

When not to change it

To Google, a different slug means a different page. Changing it on a page that is already indexed means the old address returns a 404 unless you set up a permanent redirect rather than a temporary 302, and every external link pointing to the page now goes through an extra hop. The full list of cases is in common URL problems; two rules are enough here.

  • If the slug is merely imperfect (one word too many, a stray article) leave it where it is. The gain does not cover the risk.
  • If it is visibly wrong (percent-encoding, a numeric ID, a typo, the wrong language) change it, add a 301 redirect and check that internal links point to the new address and not to the redirect. And remember the canonical tag, which is often left on the old value after a slug change.

This kind of check is part of any technical SEO work and is one of the first things we look at in our SEO projects: a site crawl with a column for path length shows you in ten minutes where the CMS has generated slugs on its own.

One last point, rarely made in the industry: the slug is the only on-page element you cannot test. You can rewrite a title on Tuesday and put it back on Friday without anyone noticing; the same goes for an H1 or a meta description. Not the slug: every change is a new address, one more redirect to maintain for years and one more line in a configuration that someone will have to read in 2031. It is the one piece of on-page SEO worth getting right once instead of optimising later, and the one where the right decision is almost always the most boring one.

Frequently asked questions

What is the difference between a slug and a URL?

The URL is the full address of the page, protocol and domain included. The slug is a single segment of the path, usually the last one, which identifies the individual page: in https://www.visilay.com/blog/url-slug/ the slug is url-slug.

Does the slug affect Google rankings?

Very little, directly. Google Search Central treats URL structure as a matter of readability and crawling, not as a ranking lever. The slug matters for other reasons: readers understand what they will find before they click, people linking to the page by hand write a sensible address, and whoever has to tidy up a large site can tell what they are looking at.

Can I use accented letters or apostrophes in a slug?

Technically yes, because they get percent-encoded, but it is better to avoid them. RFC 3986 allows only ASCII letters, digits, hyphen, full stop, underscore and tilde without encoding, and Google asks for characters outside the ASCII range to be percent-encoded. An accented e becomes %C3%A9 and an apostrophe becomes %27, so an address that looks readable in the browser turns unreadable as soon as it is copied or ends up in a report.

How long should a slug be?

Google sets no limit, and CMS limits are very high: in WordPress the post_name column is a varchar(200), and Squarespace allows 3 to 250 characters for pages. In practice two to four words are enough, because beyond that you are repeating in the slug what is already in the title and the H1.

What happens if I change the slug of a page that is already indexed?

The old address stops existing. Without a 301 redirect it returns a 404 and loses the links that pointed to the page. If you decide to change it, set up the redirect, update internal links so they point to the new address and check the canonical tag, which is often left on the previous value after a slug change.

Hyphens or underscores to separate words?

Hyphens. Google Search Central says so explicitly: it recommends hyphens instead of underscores, because underscores have historically been used to join concepts that should be read as a single word.

Matteo Pellegrini

Matteo Pellegrini

I’m a Business Developer, and at Visilay I focus on developing data-driven SEO, Google Ads, and CRO strategies. I love historical museums, have been practicing Karate for as long as I can remember, and on weekends I enjoy exploring Italian villages in search of authentic local food.