Is it valid (and maybe even a best practice) to create Aliases or Slugs that contain numbers and question marks? The numbers would be integer only, floats are out of the question.For example: example.com/do-you-want-2-or-3-?
Is it valid to include digits and question marks in the URL slug for a permalink?
url;permalinks;url slug;symbols
Definition of slugSlug is not a technically defined term. Depending on who uses/defines the term, there are different criteria involved. For example, the definition from Django says that a slug can only contain letters, numbers, underscores or hyphens, while the definition from WordPress doesnt restrict this. But its probably not useful to look how the term is defined by various CMS, as each system has its own technical vocabulary.In my opinion, the following definition for slug (in the context of URLs) makes sense:it describes the documents main content in a human-readable way, typically by representing the content titleit is typically in the path component, where it is typically the last path segmentAllowed charactersFollowing that definition, valid is every character that is allowed in the path component of the URL. For HTTP(S) URLs, these would be:a-zA-Z0-9: @ - . _ ~ ! $ & ' ( ) * + , ; = any character in its percent-encoded formAs you can see, the ? is not allowed directly. That is because ? is a reserved character which starts the query component of the URL. So if you want to include a question mark in your slug, you have to percent-encode it with %3F. While it doesnt appear to be human-readable, note that this string is not necessarily shown to the user. Many browsers will show the decoded form (i.e., %3F as ?) in the address bar.Content title to slugYou have to make several decisions about how to represent a content title in the URL. This depends on the language of the content, your backend, the URL design of other pages on your site, etc. For example: Which case to use? The path is case-sensitive; many use all lower case.How to represent space characters (if not wanting to use percent-encoded space)? Common choices are - and _.Which maximum length? Titles can be very long, but it can make sense to have shorter slugs.Any words to omit? Some may decide not to include stop words like a, the, etc.Any characters to omit? Some may decide not to represent characters like -/_ (as it may conflict with the delimiting character, see above), or punctuation marks, or special characters, etc.If your title is Do you want 2 or 3?, using 2 and 3 (instead of two and three) in the slug would be the obvious choice. Theres nothing wrong with that, and I would not change the digits to words, or even omit the digits. Think of titles like Web 2.0, Version 1.4 released, or 333333 visitors.And vice versa, if your title is Do you want two or three?, theres no reason to use 2/3 in the slug.ExamplesThis very question:Title: Is it valid to include digits and question marks in the URL slug for a permalink?URL: https://webmasters.stackexchange.com/questions/90615/is-it-valid-to-include-digits-and-question-marks-in-the-url-slug-for-a-permalinkSlug: is-it-valid-to-include-digits-and-question-marks-in-the-url-slug-for-a-permalinkA Wikipedia article:Title: DsseldorfURL: https://en.wikipedia.org/wiki/D%C3%BCsseldorfSlug: D%C3%BCsseldorf DsseldorfAs you can see, Stack Exchange uses all lower case letters, while Wikipedia differs between case. In this example you can see that Wikipedia uses _ to represent spaces, while Stack Exchange uses -. Wikipedia includes characters like . (example: Web_2.0), while Stack Exchange omits these (example: web-2-0).ConclusionTheres no right or wrong way, as long as you follow the rules from the URI standard and the HTTP(S) specification.Using digits in the slug is perfectly fine. Use the variant which you use in your content title.Using question marks in the slug is only allowed in their percent-encoded form. You may decide to omit this character (or all characters which would have to be percent-encoded), but thats not necessary.