# Waarom genereert mijn site nog steeds een gecodeerde slug, zelfs als SiteSetting.slug\_generation\_method = none?

**URL:** https://meta.discourse.org/t/why-does-my-site-still-generate-encoded-slug-even-if-sitesetting-slug-generation-method-none/246496
**Category:** Bug
**Created:** [23 november 2022 om 04:39 UTC](https://meta.discourse.org/t/why-does-my-site-still-generate-encoded-slug-even-if-sitesetting-slug-generation-method-none/246496 "2022-11-23T04:39:43Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![topological](https://avatars.discourse-cdn.com/v4/letter/t/b487fb/32.png) [@topological](https://meta.discourse.org/u/topological)
#### Post date: [23 november 2022 om 04:39 UTC](https://meta.discourse.org/t/why-does-my-site-still-generate-encoded-slug-even-if-sitesetting-slug-generation-method-none/246496/1 "2022-11-23T04:39:43Z")

</div>

Some days before, I set `SiteSetting.slug_generation_method` to encoded, trying to start a chat channel (but not enable chat plugin at all). I see the url is ugly in Chinese locale, so I `SiteSetting.slug_generation_method` back to none.

However, the site is still generating slug in new topics (not all, but a few). I have no idea what’s wrong with this. I tried to `Topic.update_all(slug: "topic")` or `Topic.update_all(slug: nil)` to refresh slug, but still some topics’ slugs are encoded title.

---

<div class="post-metadata">

### Author: ![topological](https://avatars.discourse-cdn.com/v4/letter/t/b487fb/32.png) [@topological](https://meta.discourse.org/u/topological)
#### Post date: [23 november 2022 om 11:43 UTC](https://meta.discourse.org/t/why-does-my-site-still-generate-encoded-slug-even-if-sitesetting-slug-generation-method-none/246496/2 "2022-11-23T11:43:31Z")

</div>

Another problem is that I cannot enter a topic with encoded slug , getting ERR\_TOO\_MANY\_REDIRECTS. This kind of topics with encoded slug are generated after I set SiteSetting.slug\_generation\_method to none.

The log shows

```plaintext
Started GET "/t/%E6%88%91%E4%B9%9F%E8%83%BD%E6%89%BE%E5%88%B0%E5%B1%9E%E4%BA%8E%E6%88%91%E7%9A%84%E9%98%B3%E5%85%89%E5%A4%A7%E7%94%B7%E5%AD%A9%E5%90%97/112562/39" for 10.182.185.76 at 2022-11-23 19:35:09 +0800
  Rendered text template (Duration: 0.0ms | Allocations: 1)
Processing by TopicsController#show as HTML
  Parameters: {"slug"=>"我也能找到属于我的阳光大男孩吗", "topic_id"=>"112562", "post_number"=>"39"}
Redirected to https://my-domain/t/%E8%BF%98%E6%9C%89%E4%B8%8D%E5%88%B040%E5%A4%A9%EF%BC%8C2022%E5%B9%B4%E5%B0%B1%E7%BB%93%E6%9D%9F%E4%BA%86%EF%BC%8C%E8%AF%B7%E7%94%A8%E4%B8%80%E4%B8%AA%E5%AD%97%E6%88%96%E8%80%85%E8%AF%8D%E8%AF%AD%E6%9D%A5%E8%AF%84%E4%BB%B7%E5%AE%83%E5%90%A7/112489
Completed 301 Moved Permanently in 176ms (ActiveRecord: 0.0ms | Allocations: 19880)

```

I read the code, maybe `slugs_do_not_match` return true, as `%E6%88%91%E4%B9%9F%E8%83%BD%E6%89%BE%E5%88%B0%E5%B1%9E%E4%BA%8E%E6%88%91%E7%9A%84%E9%98%B3%E5%85%89%E5%A4%A7%E7%94%B7%E5%AD%A9%E5%90%97` != `我也能找到属于我的阳光大男孩吗`。And this cause a redirect.

```plaintext
  def slugs_do_not_match
    if SiteSetting.slug_generation_method != "encoded"
      params[:slug] && @topic_view.topic.slug != params[:slug]
    else
      params[:slug] && CGI.unescape(@topic_view.topic.slug) != params[:slug]
    end
  end

```

So the problem is the same, i.e., why my site generates encoded slug when SiteSetting.slug\_generation\_method is already none.
