When sharing a question, the link given by the share button is of the form https://meta.stackexchange.com/q/[question ID]/[user ID] (e.g., https://meta.stackexchange.com/q/5436/178179)

Why are links to comments (as given when clicking on the date of a comment) not permalinks? E.g. why do we get https://meta.stackexchange.com/questions/5436/direct-link-to-a-comment#comment319306_5436 instead of something like https://meta.stackexchange.com/q/5436/319306/178179?


3 Answers 3


As Servy notes, it is a permalink. If you really want to, you could shorten the link yourself (or write a script to do it). For example, this comment:


Note the anchor: comment943339_290558

This URL also works:


The comment links are permalinks. The link to that comment will be valid for as long as that comment exists.

It's not a shortened link. It could be made more breif, if SE wanted to, but it's not transient. There's no temporary or fragile data in the URL that could be changed (while the comment is still visible).


Here's an explanation, from Shog in chat (slight grammar/formatting edits mine):

Shog: The actual reason there [is] historical: stable links to comments didn't exist for a long time after comments were introduced. They were added (if memory serves) originally to allow inbox notifications to link to the specific comment instead of the post, and thus relied on client-side script to expand comments if necessary before scrolling the comment into view and highlighting.

Remember also that the fragment isn't passed to the server, so there's two things that need to happen for them to work:

  1. The fragment-free URL needs to contain enough information for the server to load the correct page (for questions with multiple pages of answers)
  2. The fragment itself needs to contain enough information for the script to identify the correct post (since looking the comment up by ID won't work if it isn't among the comments loaded by default), load the full set of comments if the linked comment isn't visible, and then find the comment (so both post ID and comment ID).

Yeah, it's hacky and weird, which is another reason why it took so long to have comment permalinks; in hindsight, a different URL format would've probably been a good idea, but... Kinda too late now.

Me: Oh right. So for the permalink case, though, it just generates a redirect with an anchor and then the client-side still loads the appropriate comments as needed, though, right?

Shog: Right. The critical need there is to have the correct PostId, otherwise the wrong page may load. This is notable because the mod tools screw this up, making comment flags on questions with multiple pages of answers a massive headache.

My previous not-quite-right guess:

As the other answers note you can construct anchor-free links if you'd like.

I'm pretty sure (but I'm not an experienced web developer) the design reasons for this are:

  • To prevent full page reloads when following a comment link from the same page (e.g. when being linked from an answer on the same page, for example).
  • In general, anchors are really the only convenient option for linking to a location within a page. So there's got to be anchor links, providing and handling the permalinks is an extra step explicitly added only as a convenience.
  • For the anchor-free form the server has to transform that into a redirect with an anchor anyways in order to get it to scroll down the page (note that this happens when following answer perma-links too). For the anchor form it just serves the page then the client scrolls there. So I suppose it's less that the server has to do. Related to this it probably facilitates server-side caching in ways that I don't understand, too.

I think to understand whether or not those points are compelling probably requires some statistics on how many posted comment links are links within the same page. There's two contexts: You're following comment links within a page, or your following them from a different page. Providing the anchor form gives benefits to the former with no cost to the latter.

I'm attempting to construct an SEDE query that extracts question / answer / comment link counts from questions / comments / answers to get a data point on how many links are actually being posted here, although I'm having trouble with it. If I do I'll post the results here, not sure if they're meaningful. I feel like without stats here, most of this answer may be me talking out of my, how you say, wazoo.

You must log in to answer this question.

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