# 未包含主题 ID 时，入站链接不会显示

**URL:** <https://meta.discourse.org/t/inbound-links-dont-show-up-when-topic-id-is-not-included/100551>\
**Category:** UX\
**Created:** [2018年十月26日 14:01 UTC](https://meta.discourse.org/t/inbound-links-dont-show-up-when-topic-id-is-not-included/100551 "2018-10-26T14:01:51Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![mcwumbly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mcwumbly/32/103861_2.png) [@mcwumbly](https://meta.discourse.org/u/mcwumbly)\
**Post date:** [2018年十月26日 14:01 UTC](https://meta.discourse.org/t/inbound-links-dont-show-up-when-topic-id-is-not-included/100551/1 "2018-10-26T14:01:51Z")

</div>

Some just posted a topic on our forum that links to several other topics.

I was trying to figure out why the inbound links didn’t show up on the target topic and then I noticed that for some reason, they trimmed the topic ID from the link, for example, they posted something like:

```plaintext
https://meta.discourse.org/t/topic-list-previews/

```

Instead of:

```plaintext
https://meta.discourse.org/t/topic-list-previews/41630/613

```

Pasting the [unescaped example above](https://meta.discourse.org/t/topic-list-previews/) as well to illustrate here (so if you click that link, you should go to the Topic List Previews topic, but notice there’s no link on that topic back to this one).

Apparently that puts things in a state where the links to the topics work, but the inbound links on the destination don’t show up.

I’m not sure any change is warranted in the software regarding this issue, so I’m going to just advise the user to not trim the ID, but I thought it was interesting and worth documenting here.

---

<div class="post-metadata">

**Author:** ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)\
**Post date:** [2018年十月26日 14:05 UTC](https://meta.discourse.org/t/inbound-links-dont-show-up-when-topic-id-is-not-included/100551/2 "2018-10-26T14:05:46Z")

</div>

That makes sense, the inbound link is incomplete without the topic ID and breaks totally if the topic title is changed. If you visit the URL without a topic ID the location in the header is amended to show the topic ID.

Throw your broken URL into `curl --head` to see what I’m referring to.

---

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [2018年十月26日 14:06 UTC](https://meta.discourse.org/t/inbound-links-dont-show-up-when-topic-id-is-not-included/100551/3 "2018-10-26T14:06:05Z")

</div>

Removing the ID also causes the link to break should the topic be renamed.

---

<div class="post-metadata">

**Author:** ![mcwumbly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mcwumbly/32/103861_2.png) [@mcwumbly](https://meta.discourse.org/u/mcwumbly)\
**Post date:** [2018年十月26日 14:09 UTC](https://meta.discourse.org/t/inbound-links-dont-show-up-when-topic-id-is-not-included/100551/4 "2018-10-26T14:09:56Z")

</div>

I was surprised the link worked at all, (even while the name matches). If I’d propose any change here it would be to make that stop working.

---

<div class="post-metadata">

**Author:** ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)\
**Post date:** [2018年十月26日 14:11 UTC](https://meta.discourse.org/t/inbound-links-dont-show-up-when-topic-id-is-not-included/100551/5 "2018-10-26T14:11:52Z")

</div>

Why? It’s a simple convenience to preserve links where possible, if the stub matches are there any disadvantages to not punishing the user with an error?

Are we assuming that users always check links prior to posting? If so your users are much more disciplined than some of ours!

I would argue that working links are more important than working link tracking, but that could just be me.

---

<div class="post-metadata">

**Author:** ![mcwumbly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mcwumbly/32/103861_2.png) [@mcwumbly](https://meta.discourse.org/u/mcwumbly)\
**Post date:** [2018年十月26日 14:15 UTC](https://meta.discourse.org/t/inbound-links-dont-show-up-when-topic-id-is-not-included/100551/6 "2018-10-26T14:15:17Z")

</div>

I guess it depends on the tradeoff about links breaking after renames… I’m not going to make a strong case either way, just saying that’s the only sensible alternative to the current behavior that I see…

In this case, I’m not going to bother editing the post. If the link breaks due to a rename later and someone complains, then we can edit the post to fix it.

Given that, “do nothing” still seems like the most reasonable action to take here…

---

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [2018年十月26日 21:52 UTC](https://meta.discourse.org/t/inbound-links-dont-show-up-when-topic-id-is-not-included/100551/7 "2018-10-26T21:52:09Z")

</div>

It’s sometimes convenient to have the `/t/slug` work (e.g., if the data was imported). It takes a very particular kind of user to remove the `id` from the end of the URL, so it’s very rare for a user to edit the URL **and** for the topic to be renamed.

---

<div class="post-metadata">

**Author:** ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)\
**Post date:** [2018年十月30日 05:45 UTC](https://meta.discourse.org/t/inbound-links-dont-show-up-when-topic-id-is-not-included/100551/8 "2018-10-30T05:45:50Z")

</div>

We definitely want to capture the the tracking, did you test if renamed slugs are tracked, that is a far more common case…

Eg: `https://meta.discourse.org/t/old-slug/100551`

---

<div class="post-metadata">

**Author:** ![mcwumbly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mcwumbly/32/103861_2.png) [@mcwumbly](https://meta.discourse.org/u/mcwumbly)\
**Post date:** [2018年十月30日 15:35 UTC](https://meta.discourse.org/t/inbound-links-dont-show-up-when-topic-id-is-not-included/100551/9 "2018-10-30T15:35:53Z")

</div>

Nope, just assumed that still works fine

---

<div class="post-metadata">

**Author:** ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)\
**Post date:** [2019年十二月3日 05:53 UTC](https://meta.discourse.org/t/inbound-links-dont-show-up-when-topic-id-is-not-included/100551/11 "2019-12-03T05:53:37Z")

</div>

这件事我一直记在清单上，能把它划掉就好了。

@kris.kotlarek 你能看看需要做什么来解决这个追踪问题，使其对重定向具有鲁棒性吗？

---

<div class="post-metadata">

**Author:** ![kris.kotlarek](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kris.kotlarek/32/176919_2.png) [@kris.kotlarek](https://meta.discourse.org/u/kris.kotlarek)\
**Post date:** [2021年三月18日 07:32 UTC](https://meta.discourse.org/t/inbound-links-dont-show-up-when-topic-id-is-not-included/100551/14 "2021-03-18T07:32:46Z")

</div>

最终测试：  
[上方的未转义示例](https://meta.discourse.org/t/topic-list-previews/)

已编辑：  
现在可以了 🙂  
这是为了测试该漏洞是否仍然存在，因为在我的本地机器上它运行正常。这个问题很久以前就创建了，所以也许现在已经修复了。

我看到一个入站链接：  
 ![Screen Shot 2021-03-18 at 6.33.28 pm](https://cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/meta/original/3X/6/5/6506860053b6d48ba821351edc2898873316d08a.png)

---

<div class="post-metadata">

**Author:** ![kris.kotlarek](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kris.kotlarek/32/176919_2.png) [@kris.kotlarek](https://meta.discourse.org/u/kris.kotlarek)\
**Post date:** [2021年三月18日 07:34 UTC](https://meta.discourse.org/t/inbound-links-dont-show-up-when-topic-id-is-not-included/100551/15 "2021-03-18T07:34:30Z")

</div>


