# Issue with category links in no JS mode

**URL:** https://meta.discourse.org/t/issue-with-category-links-in-no-js-mode/23716
**Category:** Bug
**Created:** [6 يناير 2015، 11:47م UTC](https://meta.discourse.org/t/issue-with-category-links-in-no-js-mode/23716 "2015-01-06T23:47:29Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Mooash](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mooash/32/189167_2.png) [@Mooash](https://meta.discourse.org/u/Mooash)
#### Post date: [6 يناير 2015، 11:47م UTC](https://meta.discourse.org/t/issue-with-category-links-in-no-js-mode/23716/1 "2015-01-06T23:47:30Z")

</div>

If you view a Discourse instance with the Googlebot Useragent so that Discourse prints the instance without JS at the top of a topic it gives a link back to the category in the format `http://example.com/category/category_name`

This link then redirects to back to the shorter version, `http://example.com/c/category_name`

The issue is if the above category is a subcategory, that second link is a 404, it should be linking to the correct location, ie `http://example.com/c/parent_category/category_name`

This issue doesn’t appear when you have JS enabled/aren’t the Googlebot.

Happy to give and info if wanted! You CAN repeat this on [https://meta.discourse.org](https://meta.discourse.org) by using [this](https://meta.discourse.org/t/category-definition-for-wordpress/12282) post for example and CURLing the URL it gives back to the category listing.

```plaintext
macbook-air:~ $ curl -IL https://meta.discourse.org/category/wordpress
HTTP/1.1 302 Found
Server: nginx
Date: Tue, 06 Jan 2015 23:46:22 GMT
Content-Type: text/html; charset=utf-8
Status: 302 Found
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Location: https://meta.discourse.org/c/wordpress
Set-Cookie: destination_url=https%3A%2F%2Fmeta.discourse.org%2Fcategory%2Fwordpress; path=/; Secure
Set-Cookie: _forum_session=BAh7BkkiD3Nlc3Npb25faWQGOgZFVEkiJTZmNWI0ZDRmN2VjMjgwYjcxZDUwYWU1YzBmM2YwOTMwBjsAVA%3D%3D--eec8fe7c8eff16a59a7b780f2f23311498727b2b; path=/; HttpOnly; Secure
X-Request-Id: 4ab71e35-9a4f-4bdf-a9f9-b345f42dfb0a
X-Runtime: 0.019158
X-UA-Compatible: IE=edge
Strict-Transport-Security: max-age=31415926

HTTP/1.1 404 Not Found
Server: nginx
Date: Tue, 06 Jan 2015 23:46:22 GMT
Content-Type: text/html; charset=utf-8
Vary: Accept-Encoding
Status: 404 Not Found
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Set-Cookie: destination_url=https%3A%2F%2Fmeta.discourse.org%2Fc%2Fwordpress; path=/; Secure
Set-Cookie: _forum_session=BAh7BkkiD3Nlc3Npb25faWQGOgZFVEkiJThhZTRiNmI3ZTkyNDVmMmE5MjYxNzE1OWNlZmJiNzQyBjsAVA%3D%3D--8c98906a8920b80c989a0cf916802b677fea4ed6; path=/; HttpOnly; Secure
X-Request-Id: 4869fed5-535c-4253-a440-4c4f72da1147
X-Runtime: 0.090909
Strict-Transport-Security: max-age=31415926

macbook-air:~ $

```

---

<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: [6 يناير 2015، 11:57م UTC](https://meta.discourse.org/t/issue-with-category-links-in-no-js-mode/23716/2 "2015-01-06T23:57:06Z")

</div>

Hmm, yeah, there are a few places we were still using the old legacy `/category/foo` vs `/c/foo`.

Definitely affected the RSS page and no-JS pages, I checked in a change to see if that helps. Not sure on subcategory handling though.

---

<div class="post-metadata">

### Author: ![Mooash](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mooash/32/189167_2.png) [@Mooash](https://meta.discourse.org/u/Mooash)
#### Post date: [7 يناير 2015، 12:18ص UTC](https://meta.discourse.org/t/issue-with-category-links-in-no-js-mode/23716/3 "2015-01-07T00:18:46Z")

</div>

Thanks! I’ll wait for the commit to go into the `tests-passed` branch and get back to you.

---

<div class="post-metadata">

### Author: ![Mooash](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mooash/32/189167_2.png) [@Mooash](https://meta.discourse.org/u/Mooash)
#### Post date: [7 يناير 2015، 1:11ص UTC](https://meta.discourse.org/t/issue-with-category-links-in-no-js-mode/23716/4 "2015-01-07T01:11:06Z")

</div>

Ahh. The build failed so I’ll have to wait for it to pass at this point. [Travis CI](https://travis-ci.org/discourse/discourse/builds/46139399)

@codinghorror your fix gets rid of the redirect, but `http://example.com/c/category_name` still gets a 404 since its a subcategory sadly!

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [7 يناير 2015، 3:55ص UTC](https://meta.discourse.org/t/issue-with-category-links-in-no-js-mode/23716/5 "2015-01-07T03:55:33Z")

</div>

Try `c.url` instead of `c.slug` if that’s used anywhere in the output?

---

<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: [7 يناير 2015، 5:27ص UTC](https://meta.discourse.org/t/issue-with-category-links-in-no-js-mode/23716/6 "2015-01-07T05:27:05Z")

</div>

That is a bug @eviltrout will have to fix with subcategories not displaying as proper URLs in RSS…

---

<div class="post-metadata">

### Author: ![Mooash](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mooash/32/189167_2.png) [@Mooash](https://meta.discourse.org/u/Mooash)
#### Post date: [7 يناير 2015، 5:48ص UTC](https://meta.discourse.org/t/issue-with-category-links-in-no-js-mode/23716/7 "2015-01-07T05:48:39Z")

</div>

This happens in the non-JS versions of pages as well, btw! 😄

---

<div class="post-metadata">

### Author: ![Moter8](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moter8/32/120941_2.png) [@Moter8](https://meta.discourse.org/u/Moter8)
#### Post date: [7 يناير 2015، 6:52ص UTC](https://meta.discourse.org/t/issue-with-category-links-in-no-js-mode/23716/8 "2015-01-07T06:52:28Z")

</div>

Also see

[https://meta.discourse.org/t/wrong-links-to-subcategory-in-noscript-tags-in-a-thread/22641](https://meta.discourse.org/t/wrong-links-to-subcategory-in-noscript-tags-in-a-thread/22641)

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [7 يناير 2015، 4:47م UTC](https://meta.discourse.org/t/issue-with-category-links-in-no-js-mode/23716/9 "2015-01-07T16:47:56Z")

</div>

I’ve got a fix incoming for this. Let me know if I missed anything:

[https://github.com/discourse/discourse/commit/114cc1c8510fc3fbd677f5bbfc0be6ae86877267](https://github.com/discourse/discourse/commit/114cc1c8510fc3fbd677f5bbfc0be6ae86877267)

---

<div class="post-metadata">

### Author: ![Mooash](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mooash/32/189167_2.png) [@Mooash](https://meta.discourse.org/u/Mooash)
#### Post date: [7 يناير 2015، 8:31م UTC](https://meta.discourse.org/t/issue-with-category-links-in-no-js-mode/23716/10 "2015-01-07T20:31:39Z")

</div>

Confirmed working for me.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [7 يناير 2015، 8:37م UTC](https://meta.discourse.org/t/issue-with-category-links-in-no-js-mode/23716/11 "2015-01-07T20:37:04Z")

</div>


