Answers.Body: <p>Basically not possible with Craft, currently.</p>
  <p>Slugs go through a <a href="https://github.com/craftcms/cms/blob/develop/src/helpers/ElementHelper.php#L100-L124" rel="nofollow noreferrer">normalizeSlug()</a> helper that removes what it thinks is HTML and inner-word punctuation.</p>
  <p>What I suspect is tripping you up is when it splits on &quot;words&quot; here: <a href="https://github.com/craftcms/cms/blob/develop/src/helpers/ElementHelper.php#L121" rel="nofollow noreferrer">https://github.com/craftcms/cms/blob/develop/src/helpers/ElementHelper.php#L121</a></p>
  <p>Where only <code>.</code>, <code>|</code> and <code>-</code> are allowed punctuation, stripping out everything else.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-06-01T23:59:18.913Z
Answers.LastActivityDate: 2021-06-03T03:50:32.320Z
Answers.LastEditDate: 2021-06-03T03:50:32.320Z
Answers.UserDisplayName: Brad Bell
Body: <p>I need to output a slug that will include characters like &lt; and |. I realise that these can't be literal, so I had hoped to be able to swap them out for the URL encoded equivalents.</p>
  <p>For example, the slug <code>l&lt;t</code></p>
  <p>Would become: <code>l%3Ct</code></p>
  <p>Right now, though, if I actually try and save the entry it strips out all of the percent symbols (<code>%</code>) rendering the encoding useless. Is there a way to turn off this behaviour? Or escape the symbols somehow?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-06-01T19:20:52.333Z
Comments.Text: Just curious as to your use case for this? If they are being used as URLs, you usually want them short and straightforward…
Comments.UserDisplayName: RitterKnight
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-06-01T19:48:33.410Z
Comments.Text: I'm building a database, where the slug should be the product name. Some products have these kinds of characters in their names, which would ideally be represented in the URL. If the slug could accept URI encoded characters, then it'll all work nicely, as browsers will interpret the real characters correctly. (If that last part doesn't sound like I would work, I should mention that I don't serve anything direct from Craft, but via the Elements API, so it does indeed work.)
Comments.UserDisplayName: theAdhocracy
Tags: <slug><entry-slug>
Title: Special Characters in Slugs
ThreadText: # Special Characters in Slugs
  
  (Asked by: username_0 on 2021-06-01)
  
  I need to output a slug that will include characters like < and |. I realise that these can't be literal, so I had hoped to be able to swap them out for the URL encoded equivalents.
  
  For example, the slug `l<t`
  
  Would become: `l%3Ct`
  
  Right now, though, if I actually try and save the entry it strips out all of the percent symbols (`%`) rendering the encoding useless. Is there a way to turn off this behaviour? Or escape the symbols somehow?
  
  **Tags:** slug, entry-slug
  
  > **Comments:**
  > **username_1**: Just curious as to your use case for this? If they are being used as URLs, you usually want them short and straightforward…  
  > **username_0**: I'm building a database, where the slug should be the product name. Some products have these kinds of characters in their names, which would ideally be represented in the URL. If the slug could accept URI encoded characters, then it'll all work nicely, as browsers will interpret the real characters correctly. (If that last part doesn't sound like I would work, I should mention that I don't serve anything direct from Craft, but via the Elements API, so it does indeed work.)  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2021-06-01. Score: 2 | Accepted answer
  
  Basically not possible with Craft, currently.
  
  Slugs go through a [normalizeSlug()](https://github.com/craftcms/cms/blob/develop/src/helpers/ElementHelper.php#L100-L124) helper that removes what it thinks is HTML and inner-word punctuation.
  
  What I suspect is tripping you up is when it splits on "words" here: <https://github.com/craftcms/cms/blob/develop/src/helpers/ElementHelper.php#L121>
  
  Where only `.`, `|` and `-` are allowed punctuation, stripping out everything else.
  
  
  ---
  
  