Internal Link Shortcuts

Today I was looking for a way to link to a post in the same topic.

The :link: icon, when clicked, shows post #4, so I tried: using #4 and post#4, only to get frustrated, but discovering that the # character pops up categories to link (which I read about extensively since, in meta.)

Now, I find this quite inconsistent, and would like to propose ways to consistently address internal links that matches the actual URL format, or already used patterns…

Generic Patterns

Using colon as a prefix or separator would be nice, but it already autocompletes to emoticons and that could become messy. But consider: :4, :10:4, and 3:10:4 (with optional colon prefix) to link to post number 4 in the current topic, post number 4 in topic 10, and post number 4 in topic 10 of category 3.

Using / instead might work, but then it should match the URL, e.g., /c/3, /t/10, and /t/10/4.

The “quote reply” to a post uses keyword colon number, e.g., post:4 or topic:123. This can be very useful is there’s a way to show these IDs with every post (e.g., with an element title or tooltip).

In general though, #post_4 would use the actual anchor in the HTML. #4 would be great too, but it conflicts with the (current) category shortcut (BTW, what happens when you have a category name matching a tag name?)

Both solutions though are problematic for i10n since they impose English words.

The shortcut to a post in the current topic should make category and topic implicit.

Since topic IDs are global, .. can be useful, as in .[optional topic ID].[post number], e.g.:

  • ..4 to link to post #4 in current topic
  • .10.4 to link to post #4 in topic 10
1 个赞

Use the URL to the post. You can also edit the URL to make it refer to a specific post number in the topic as needed.

1 个赞

But that requires using the mouse instead of the keyboard, doesn’t it?

1 个赞

You can use j and k to navigate through the posts and the URL changes accordingly, so you can ^L^C to copy the URL of the current post.

Except it’s off by one:

https://meta.discourse.org/t/url-off-by-one-when-moving-through-posts-with-keyboard/50925

4 个赞

有没有办法使用相对 URL,例如 /t/50904,而不是 https://meta.discourse.org/t/50904

测试直接粘贴完整 URL:Internal Link Shortcuts - #4 by pfaffman

(我只是想理清使用完整 URL 来引用同一服务器上的链接这一概念,这似乎存在协议或主机名过时的风险……在我的情况下,我们有一个位于防火墙后的 Discourse http: 实例,尚未迁移到 TLS。因此,如果我们有很多 http: 内部链接,当 URL 更改为 https: 时,这些链接是否会失效?)

标准的 HTML 应该可以正常工作

<a href="/t/internal-link-shortcuts/50904/6">Link</a> 应变为 Link

Markdown 也应该可以正常工作,

[Link](/t/internal-link-shortcuts/50904/6) 应变为 Link

4 个赞

除非你认为每个用户每次都会为了没有即时收益而重写他们的 URL,否则在更改协议时无论如何都需要进行重映射。当然,在生成 URL 时你可能愿意这样做,但大多数人不会。将 http://yourdomain/ 重映射到 https://yourdomain 并不是什么大事。

这是我们计算机从业者会担心但实际上并无影响的那种事情。这真的非常非常困难,但你应该放手。:wink:

2 个赞

试试看……用 /t/50904/6

链接到第 6 条帖子

太棒了!谢谢

4 个赞