7

On a Stack Exchange site, you can get a link to a comment if you click on the timestamp next to the comment. The exact URL might be a bit different depending on the way you arrived to the comment. In particular, the link you get after visiting an answer might look like this: https://meta.stackexchange.com/questions/357653/is-there-a-site-for-greek-language/357654#comment1194927_357654. You can check for yourself that you get this link if you visit this answer and then click on the timestamp. And also that said link actually goes to the comment.

Probably a bug: The links do not work the same way, if you change the part of the URL corresponding to the title. In particular, this might mean that if the title was edited, the link you got from the timestamp before the edit no longer works.

In this example, if I change to the URL corresponding to the previous title of the question, i.e., to https://meta.stackexchange.com/questions/357653/is-there-a-site-for-greek-language-exchange/357654#comment1194927_357654 then this link no longer brings you to the comment, but it goes to an answer instead.

I looked into links based on answers because I wanted to find whether there is some way of getting an URL of a comment, which works also for questions with several pages of answers. However, I did not find a way to shorten such a link. (Since one user complained that there are problems with this when writing comments. In a comment, there is a character limit, which is an incentive to shorten links when possible.)

Additional question: Is there a way of linking to comments, which would be reliable even for a comment under an answer which is not necessarily on the first page of answers (i.e., not displayed together with the question), where the link would not be excessively long?

  • @rene Indeed, that's what I meant, thanks for the edit. (Somehow I missed this when I was checking the post.) – Martin Dec 25 '20 at 20:00
  • 1
    Normally it doesn't matter what the title is because it only cares about and up to the postid in the url. I expect the problem here is that comment identifier is sent as fragment and that causes the problem when an redirect is done to land you on the now current url with the correct title. – rene Dec 25 '20 at 20:05
  • 2
    Is there a way of linking to comments, which would be reliable even for a comment under an answer which is not necessarily on the first page of answers ... Yes, for example: https://stackoverflow.com/posts/comments/2221 ... I cheated to get that comment link – rene Dec 25 '20 at 20:12
  • 1
    @rene, your comment suggests a mechanical translation from the auto-generated link https://stackoverflow.com/questions/56078/merging-two-collectiont/56108#comment2221_56108 that simply strips out all information but the comment number—in particular, it suggests that the question number is not needed to refer to the post. Is that correct? – LSpice Dec 25 '20 at 21:07
  • 2
    @LSpice yes, for that specific route you don't need the question number (post id technically). This is because the system has one comments table for all comments in the system. It has an id as well as an postid. So once you navigate to /posts/comments/{id} the server will lookup in the comments table the row with the matching id where it then also finds the postid. With that information it can build the correct url for you and send that back as Location header where your browser takes care of it. – rene Dec 25 '20 at 21:27
  • 1
    Given that I'm used to questions having at least one comment, I was very surprised that the 2221st comment on SO should have been on the 56078th question! Are the numbers non-sequential? – LSpice Dec 25 '20 at 21:48
  • 1
    @LSpice it looks like they are generated kind of randomly. That is unexpected. – rene Dec 25 '20 at 22:07
  • 2
    On newer sites the identity column is a sequence. On the triology sites and a few other sites that I believe started on Version 1.0 of the Stack Exchange software have that non-sequential comment id. On SO the latest commentids are sequential data.stackexchange.com/stackoverflow/query/1352291 – rene Dec 25 '20 at 22:23

You must log in to answer this question.

Browse other questions tagged .