5

When adding links to comments within other comments I often want to shorten them so that I can add fit more plain text within the character limit.

I usually start by removing the words of the title and one forward slash, and sometimes remove the noredirect bit, but I recognize that I don't really know what I'm doing.

Is it possible to state best practices and offer some advice on how to best shorten links to comments when including them in other comments? What does noredirect=1 do for example, and what are the consequences of removing it?

Working examples that appear to me to be ripe for shortening:

  • https://space.stackexchange.com/questions/54293/is-there-any-demonstrated-or-even-proposed-technology-that-can-sterilize-a-space?noredirect=1#comment177960_54293
  • https://astronomy.stackexchange.com/questions/41023/why-cant-we-build-a-huge-stationary-optical-telescope-inside-a-depression-simil/41027?noredirect=1#comment83925_41027
2
  • 1
    You can always remove https:. Commented Jul 27, 2021 at 3:18
  • 2
    A while ago, I wrote an answer to Documentation for Stack Exchange engine URLs? which contains (most of) the information you're looking for (but it's buried deep) - it does not mention the possibility of relative URLs though.
    – Glorfindel Mod
    Commented Jul 27, 2021 at 5:31

2 Answers 2

6

There's an even shorter undocumented scheme for shortening comment URLs, that makes for links even shorter than Cave Johnson's answer: just take the comment ID, i.e. the first number in the #comment[x]_[y] fragment, and put it into /posts/comments/[x].

Examples:

  • https://space.stackexchange.com/questions/54293/is-there-any-demonstrated-or-even-proposed-technology-that-can-sterilize-a-space?noredirect=1#comment177960_54293

  • https://astronomy.stackexchange.com/questions/41023/why-cant-we-build-a-huge-stationary-optical-telescope-inside-a-depression-simil/41027?noredirect=1#comment83925_41027

become:

  • https://space.stackexchange.com/posts/comments/177960
  • https://astronomy.stackexchange.com/posts/comments/83925

respectively.

If the comment you're linking to is on the same site, you can drop the full URL portion and link to it as a relative URL, so these URLs would then become the following:

  • /posts/comments/177960
  • /posts/comments/83925

These only work if the linked comment is on the same site as the comment you're posting, as they omit the site part of the URL. Do note that such relative links will break if the question is subsequently migrated, so only use them if the question is older than 60 days or you're sure it won't be migrated.

4
  • 2
    It’s not quite undocumented. This is how comments are linked in the timeline. Commented Jul 27, 2021 at 3:17
  • 1
    Nice, would be cool if there was a way to get this link from the ui. Commented Jul 27, 2021 at 3:40
  • 1
    @CaveJohnson As Sebastian Simon commented, such links are given in the timeline. Commented Jul 27, 2021 at 4:03
  • 1
    This is working nicely, thanks! Does it make sense here to add a /usernumber to the end to "get credit" for folks following the link the same way that links to posts do when clicking "Share"?
    – uhoh
    Commented Aug 5, 2021 at 22:50
4

It looks like I was able to get the comment link to work even when I removed the title segment from the urls. So I changed

  • https://space.stackexchange.com/questions/54293/is-there-any-demonstrated-or-even-proposed-technology-that-can-sterilize-a-space?noredirect=1#comment177960_54293

  • https://astronomy.stackexchange.com/questions/41023/why-cant-we-build-a-huge-stationary-optical-telescope-inside-a-depression-simil/41027?noredirect=1#comment83925_41027

to:

  • https://space.stackexchange.com/q/54293?noredirect=1#comment177960_54293

  • https://astronomy.stackexchange.com/q/41023?noredirect=1#comment83925_41027

Also note I changed /questions/ to /q/ to shorten the urls further.

I guess that removing the noredirect=1 part will cause the url to redirect to a duplicate post if the question has been closed as a duplicate and the the user is not logged in/anonymous (or possibly below a certain reputation?), which could result in an undesired effect.

1
  • 3
    The redirection is specifically for anonymous users who visit an unanswered duplicate (reference). So if the question isn't close as a dupe, or has an answer, that bit could be removed as well
    – bobble
    Commented Jul 27, 2021 at 3:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .