# Slug is required in topic URL?

**URL:** <https://meta.discourse.org/t/slug-is-required-in-topic-url/45207>\
**Category:** Feature\
**Created:** [June 3, 2016, 3:47pm UTC](https://meta.discourse.org/t/slug-is-required-in-topic-url/45207 "2016-06-03T15:47:24Z")\
**Posts on this page:** 8\
**Page:** 1

## AI-generated summary

The discussion addresses an inconsistency in Discourse topic URL handling regarding the requirement of a slug. [jhands](/t/-/45207/1) reported that internal links using the format `[link](/t/45202)` result in an "Access Denied" error, whereas including a slug placeholder like `[link](/t/blah/45202)` works correctly. [tobiaseigen](/t/-/45207/2) initially clarified that the slug segment is intended to be required, noting that any value can be placed there. [jhands](/t/-/45207/3) countered that fully qualified external URLs (e.g., `https://meta.discourse.org/t/45202`) function without a slug, creating a discrepancy. [codinghorror](/t/-/45207/4) observed that the error also depends on interaction method, noting the link works if opened in a new tab. [jhands](/t/-/45207/5) argued that since the slug requirement cannot be removed globally without breaking existing links, the system should be fixed to allow `t/1234` formats within the same site for consistency. [johnmuhl](/t/-/45207/6) linked this to a previous discussion titled "Title links only work if the slug is present," which [jhands](/t/-/45207/7) confirmed was the same issue. [jhands](/t/-/45207/7) further questioned why slugs are optional for full URLs if a 1-character minimum is enforced internally. [tobiaseigen](/t/-/45207/8) acknowledged this as a valid point, admitting they were unaware of the behavior with fully qualified links and speculated it might be unintended "URL hacking" that previously did not work.

<div class="post-metadata">

**Author:** ![jhands](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jhands/32/121736_2.png) [@jhands](https://meta.discourse.org/u/jhands)\
**Post date:** [June 3, 2016, 3:47pm UTC](https://meta.discourse.org/t/slug-is-required-in-topic-url/45207/1 "2016-06-03T15:47:25Z")

</div>

I went to link a topic from another topic and noticed that `[link](/t/45202)` [produces the error](https://meta.discourse.org/t/45202)  
`Access Denied while trying to load /t/id_for/14`

However `[link](/t/blah/45202)` [works fine](https://meta.discourse.org/t/blah/45202). I believe this is a bug.

---

<div class="post-metadata">

**Author:** ![tobiaseigen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tobiaseigen/32/539204_2.png) [@tobiaseigen](https://meta.discourse.org/u/tobiaseigen)\
**Post date:** [June 3, 2016, 3:50pm UTC](https://meta.discourse.org/t/slug-is-required-in-topic-url/45207/2 "2016-06-03T15:50:24Z")

</div>

> [@jhands](#):
>
> However [link](https://meta.discourse.org/t/blah/45202) works fine. I believe this is a bug.

actually this is intended behavior. you have to have something in the `blah` spot in the URL. You can put whatever you want in there.

---

<div class="post-metadata">

**Author:** ![jhands](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jhands/32/121736_2.png) [@jhands](https://meta.discourse.org/u/jhands)\
**Post date:** [June 3, 2016, 4:17pm UTC](https://meta.discourse.org/t/slug-is-required-in-topic-url/45207/3 "2016-06-03T16:17:05Z")

</div>

But why don’t you have to put something in blah when linking the full address? [https://meta.discourse.org/t/45202](https://meta.discourse.org/t/45202) when you link on anything other than discourse. (Put that up in the address field of browser and it will work.)

---

<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:** [June 3, 2016, 4:28pm UTC](https://meta.discourse.org/t/slug-is-required-in-topic-url/45207/4 "2016-06-03T16:28:39Z")

</div>

I see what you are saying now. It also works if you open in new tab vs click directly.

---

<div class="post-metadata">

**Author:** ![jhands](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jhands/32/121736_2.png) [@jhands](https://meta.discourse.org/u/jhands)\
**Post date:** [June 3, 2016, 4:33pm UTC](https://meta.discourse.org/t/slug-is-required-in-topic-url/45207/5 "2016-06-03T16:33:17Z")

</div>

Yes exactly. It can’t exactly be removed now since it’d break a lot of links to discourse sites. So I think it should be fixed to allow t/1234 within the same Discourse site for consistency.

---

<div class="post-metadata">

**Author:** ![johnmuhl](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/johnmuhl/32/43413_2.png) [@johnmuhl](https://meta.discourse.org/u/johnmuhl)\
**Post date:** [June 3, 2016, 4:45pm UTC](https://meta.discourse.org/t/slug-is-required-in-topic-url/45207/6 "2016-06-03T16:45:34Z")

</div>

Seems similar to:

> [@Title links only work if the slug is present](https://meta.discourse.org/t/title-links-only-work-if-the-slug-is-present/32165):
>
> Links like this [https://meta.discourse.org/t/site-being-phished-on-third-party-domain/32112](https://meta.discourse.org/t/site-being-phished-on-third-party-domain/32112) work but when you only use the /t/:id part like this [https://meta.discourse.org/t/32112](https://meta.discourse.org/t/32112) you get an error instead. Reloading the error page causes the correct page to load.

---

<div class="post-metadata">

**Author:** ![jhands](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jhands/32/121736_2.png) [@jhands](https://meta.discourse.org/u/jhands)\
**Post date:** [June 3, 2016, 6:23pm UTC](https://meta.discourse.org/t/slug-is-required-in-topic-url/45207/7 "2016-06-03T18:23:52Z")

</div>

Yeah that’s the same issue (I couldn’t find that when searching.)  
@codinghorror says there that a slug of at least 1 character is required. If that’s the case, how did it end up that slugs aren’t required for fully qualified links?

---

<div class="post-metadata">

**Author:** ![tobiaseigen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tobiaseigen/32/539204_2.png) [@tobiaseigen](https://meta.discourse.org/u/tobiaseigen)\
**Post date:** [June 3, 2016, 6:29pm UTC](https://meta.discourse.org/t/slug-is-required-in-topic-url/45207/8 "2016-06-03T18:29:17Z")

</div>

> [@jhands](#):
>
> If that’s the case, how did it end up that slugs aren’t required for fully qualified links?

that’s a good point and I wasn’t aware of it. I don’t think this used to work and I’m not sure why it does.

nice URL hacking! 😉
