# Force Lowercase slug URLs when set to "encoded"

**URL:** https://meta.discourse.org/t/force-lowercase-slug-urls-when-set-to-encoded/46036
**Category:** Support
**Created:** [19.Июнь.2016 14:50:52 UTC](https://meta.discourse.org/t/force-lowercase-slug-urls-when-set-to-encoded/46036 "2016-06-19T14:50:52Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Idan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/idan/32/198212_2.png) [@Idan](https://meta.discourse.org/u/Idan)
#### Post date: [19.Июнь.2016 14:50:52 UTC](https://meta.discourse.org/t/force-lowercase-slug-urls-when-set-to-encoded/46036/1 "2016-06-19T14:50:52Z")

</div>

I wanted to know if there is an option to force lowercase slugs instead of the same capitilization it is written. I prefer lowercase URLs than mixed ones.

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [19.Июнь.2016 15:23:36 UTC](https://meta.discourse.org/t/force-lowercase-slug-urls-when-set-to-encoded/46036/2 "2016-06-19T15:23:36Z")

</div>

Looking at meta, it seems to be lower-case… can you provide an example where it isn’t lowercase?

---

<div class="post-metadata">

### Author: ![Idan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/idan/32/198212_2.png) [@Idan](https://meta.discourse.org/u/Idan)
#### Post date: [19.Июнь.2016 15:25:02 UTC](https://meta.discourse.org/t/force-lowercase-slug-urls-when-set-to-encoded/46036/3 "2016-06-19T15:25:02Z")

</div>

When I edit the title of the welcome page on my site, the title and the slug is presented in mixed case. On your site, meta, it’s ok. I also posted a topic in a category, and the slug is mixed case.

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [19.Июнь.2016 15:35:59 UTC](https://meta.discourse.org/t/force-lowercase-slug-urls-when-set-to-encoded/46036/4 "2016-06-19T15:35:59Z")

</div>

It may be a wild guess, but…

What `LANG` and `DISCOURSE_DEFAULT_LOCALE` is set in `app.yml`?

---

<div class="post-metadata">

### Author: ![Idan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/idan/32/198212_2.png) [@Idan](https://meta.discourse.org/u/Idan)
#### Post date: [19.Июнь.2016 15:39:06 UTC](https://meta.discourse.org/t/force-lowercase-slug-urls-when-set-to-encoded/46036/5 "2016-06-19T15:39:06Z")

</div>

Where is the app.yml located, I need the full path in Ubuntu. I can’t find it under /var/

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [19.Июнь.2016 15:39:36 UTC](https://meta.discourse.org/t/force-lowercase-slug-urls-when-set-to-encoded/46036/6 "2016-06-19T15:39:36Z")

</div>

If you followed the default installation steps, it’s `/var/discourse/containers/app.yml`.

---

<div class="post-metadata">

### Author: ![Idan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/idan/32/198212_2.png) [@Idan](https://meta.discourse.org/u/Idan)
#### Post date: [19.Июнь.2016 15:40:54 UTC](https://meta.discourse.org/t/force-lowercase-slug-urls-when-set-to-encoded/46036/7 "2016-06-19T15:40:54Z")

</div>

> [@fefrei](#):
>
> DISCOURSE\_DEFAULT\_LOCALE

That’s what I have there:

env:  
LANG: en\_US.UTF-8

# DISCOURSE\_DEFAULT\_LOCALE: en

---

<div class="post-metadata">

### Author: ![Idan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/idan/32/198212_2.png) [@Idan](https://meta.discourse.org/u/Idan)
#### Post date: [19.Июнь.2016 15:58:25 UTC](https://meta.discourse.org/t/force-lowercase-slug-urls-when-set-to-encoded/46036/8 "2016-06-19T15:58:25Z")

</div>

An idea how to solve this?

---

<div class="post-metadata">

### Author: ![Idan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/idan/32/198212_2.png) [@Idan](https://meta.discourse.org/u/Idan)
#### Post date: [20.Июнь.2016 09:38:32 UTC](https://meta.discourse.org/t/force-lowercase-slug-urls-when-set-to-encoded/46036/9 "2016-06-20T09:38:32Z")

</div>

Anyone can help me with this, can’t continue using the platform without being soves.

---

<div class="post-metadata">

### Author: ![Idan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/idan/32/198212_2.png) [@Idan](https://meta.discourse.org/u/Idan)
#### Post date: [20.Июнь.2016 12:00:09 UTC](https://meta.discourse.org/t/force-lowercase-slug-urls-when-set-to-encoded/46036/10 "2016-06-20T12:00:09Z")

</div>

I’ve found out that the slug is lowercase in ‘ascii’ mode, but when I change to ‘encoded’ it stays with the same letter case that I’ve written the topic with.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [20.Июнь.2016 20:59:27 UTC](https://meta.discourse.org/t/force-lowercase-slug-urls-when-set-to-encoded/46036/11 "2016-06-20T20:59:27Z")

</div>

Why do you need it in “encoded”? ASCII is correct for western languages.

---

<div class="post-metadata">

### Author: ![Idan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/idan/32/198212_2.png) [@Idan](https://meta.discourse.org/u/Idan)
#### Post date: [20.Июнь.2016 21:05:50 UTC](https://meta.discourse.org/t/force-lowercase-slug-urls-when-set-to-encoded/46036/12 "2016-06-20T21:05:50Z")

</div>

Because I want the keywords to be in the URL, even if they are written in Japanes, Chinese or any other non-English keywords.

If I use ascii, this topic title: “どういたしまして どういたしまして”

becomes

**/t/topic/17**

I used it in all my websites, it’s great for usability and make the URL meaningful in search engines after indexing, and it’s useful for SEO as well.

You already have a percentage encoding option, so you just need to apply lowercasing, so it will work as ASCII for English letters with small case and will be compatible with non-ASCII characters. Wordpress and all the other popular blog and forum software have this.

Google also shows the URL with the decoded characters, not the encoded ones.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [20.Июнь.2016 21:18:29 UTC](https://meta.discourse.org/t/force-lowercase-slug-urls-when-set-to-encoded/46036/13 "2016-06-20T21:18:29Z")

</div>

What happens when you lowercase unicode? This is complex and indeterminate. Not sure if Ruby can even do it.

---

<div class="post-metadata">

### Author: ![Idan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/idan/32/198212_2.png) [@Idan](https://meta.discourse.org/u/Idan)
#### Post date: [20.Июнь.2016 21:24:36 UTC](https://meta.discourse.org/t/force-lowercase-slug-urls-when-set-to-encoded/46036/14 "2016-06-20T21:24:36Z")

</div>

You lowercase before encoding, Every platform that I use (and I have 15 years of developing experoence, not in Ruby though), does that. It’s a missed opportunity, I will look into rubi and see what I find.

If you aim your platform for multilanguage, you have to do that.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [20.Июнь.2016 21:29:32 UTC](https://meta.discourse.org/t/force-lowercase-slug-urls-when-set-to-encoded/46036/15 "2016-06-20T21:29:32Z")

</div>

You are making inconsistent and mutually exclusive requests – the idea is that by explicitly enabling Unicode display in the URL you care about _exactly_ what characters display, whereas passing Unicode through a lowercase algorithm will mangle it.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [20.Июнь.2016 21:33:29 UTC](https://meta.discourse.org/t/force-lowercase-slug-urls-when-set-to-encoded/46036/16 "2016-06-20T21:33:29Z")

</div>

Ruby 2.4.0.preview 1 launched today with [unicode aware downcase/upcase](https://www.ruby-lang.org/en/news/2016/06/20/ruby-2-4-0-preview1-released/).

In the mean time, rails active support provides this.

If the code path isn’t critical, it can be added. Not sure if we must add tough 😄.

---

<div class="post-metadata">

### Author: ![Idan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/idan/32/198212_2.png) [@Idan](https://meta.discourse.org/u/Idan)
#### Post date: [20.Июнь.2016 21:34:02 UTC](https://meta.discourse.org/t/force-lowercase-slug-urls-when-set-to-encoded/46036/17 "2016-06-20T21:34:02Z")

</div>

Sorry, my english is not native.

This is how [wordpress does it.](https://github.com/WordPress/WordPress/blob/master/wp-includes/formatting.php#L1515)

The goal is the URL that the slug/url will be presented in the links and in the canonical as percentage encoded, so titles in different languages will appear as-is in the URL when search engine index them - and [it is important](https://moz.com/blog/15-seo-best-practices-for-structuring-urls).

So sorry for not explaining myself the right way, but for foreign language forum it has to be done. As I mentioned, all the popular forum software do that.

I am probably confusing between the two, but the thing that I don’t understand, is if you encode the URL, why not having lowercase for English characters?

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [20.Июнь.2016 21:34:58 UTC](https://meta.discourse.org/t/force-lowercase-slug-urls-when-set-to-encoded/46036/18 "2016-06-20T21:34:58Z")

</div>

Good luck – as you can see above, Ruby just added support for this. Sorry, you may wish to pick different discussion software if this is a critical requirement for you.

(it is also quite performance intensive to properly lowercase among all known human languages and character sets)

---

<div class="post-metadata">

### Author: ![Idan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/idan/32/198212_2.png) [@Idan](https://meta.discourse.org/u/Idan)
#### Post date: [20.Июнь.2016 21:36:07 UTC](https://meta.discourse.org/t/force-lowercase-slug-urls-when-set-to-encoded/46036/19 "2016-06-20T21:36:07Z")

</div>

OK, so the Rubi you are using still not suppoort it

---

<div class="post-metadata">

### Author: ![Idan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/idan/32/198212_2.png) [@Idan](https://meta.discourse.org/u/Idan)
#### Post date: [20.Июнь.2016 21:38:25 UTC](https://meta.discourse.org/t/force-lowercase-slug-urls-when-set-to-encoded/46036/20 "2016-06-20T21:38:25Z")

</div>

The Rails Active Support gem provides upcase, downcase, swapcase,capitalize, etc. methods with internationalization support:

> gem install activesupport  
> irb -ractive\_support/core\_ext/string  
> “STRING ÁÂÃÀÇÉÊÍÓÔÕÚ”.mb\_chars.downcase.to\_s  
> =\> “string áâãàçéêíóôõú”  
> “string áâãàçéêíóôõú”.mb\_chars.upcase.to\_s  
> =\> “STRING ÁÂÃÀÇÉÊÍÓÔÕÚ”

[source](http://stackoverflow.com/questions/1020568/how-to-convert-a-string-to-lower-or-upper-case-in-ruby)

Performance wise: 10000000 iterations in C#

ToLower(): 1054 ms  
ToLowerInvariant(): 1724 ms  
ToLower(CultureInfo): 884 ms [fastest]

Don’t think it’s an issue.

[Следующая страница](https://meta.discourse.org/t/force-lowercase-slug-urls-when-set-to-encoded/46036.md?page=2)
