46

MediaWiki, the software used on Wikipedia, has some cool functionality as part of its header text syntax. It makes a slug out of the text, and automatically adds that slug to the id attribute of the header tag.

Example: https://en.wikipedia.org/wiki/URL#History

It would be great if the header tags here (i.e. ###) did the same thing.

Imagine - linking straight to the Copy Editor badge description in What are the badges I can earn on each site, and what are the exact criteria for earning each badge?! Or straight to Moderator in the Stack Exchange Glossary - Dictionary of Commonly-Used Terms!

8
  • Why is this more useful than just a "link"? Why should headers be links specifically? You can make links bold, or highlighted in other ways.
    – James
    Commented Sep 15, 2015 at 2:23
  • 7
    @James What I am suggesting is to make headers link targets, so that off-site links (or other questions/answers) can target headers directly. (Notice I can't do so in the body of the question to the headers mentioned.) What kind of "link" are you comparing this to?
    – Nicole
    Commented Sep 15, 2015 at 3:01
  • 2
    This functionality exists for Articles on Teams and SO. Anchors for in-post headers were enabled SE-wide for about 2 weeks: enabled sometime between 2021-07-11 and the 14th, then disabled on 2021-07-30. At that time, the generation of id attributes needed a slight tweak to include the post's ID in the id to guarantee no duplicate id between posts on the page. Duplicates within a post would have still be possible, but that could also have been easily solved by always adding a sequence number starting at 1 in each post and increasing for each id. Making those changes should be easy.
    – Makyen
    Commented Jan 16, 2023 at 18:30
  • @MarcusMüller Just FYI: to get this on SE's radar, a status-review tag needs be added to the question. Posting a bounty brings more attention from regular users, which is helpful when the issue needs more support or input from users, but doesn't being it to SE's attention. Adding the status-review tag generates a ticket in SE's task system, which can then be triaged into an actual feature request sent to developers. To have a status-review tag added to the question, the normal process is to raise an "in need of moderator intervention" flag to request the tag be added.
    – Makyen
    Commented Jan 16, 2023 at 18:37
  • 1
    @Makyen I asked for moderator attention, asking for a status-review tagging, including a bit of reasoning. Let's see what comes out of this! Commented Jan 17, 2023 at 9:55
  • I think the manually written "Table of Contents" with no option to link to the title elements in this answer kind of well illustrate that even niche SE sites tend to benefit from this feature, and large sites like SO where answers often become very complex due to a lot of aspects coming up on popular posts would twice as much. Commented Jan 17, 2023 at 10:03
  • 1
    GitHub does the same thing in its Markdown rendering. For instance, adding-guava-to-your-build is the id that is automatically added to the (hyperlinks in the) headers for Markdown header ## Adding Guava to your build.
    – M. Justin
    Commented Aug 2, 2023 at 22:07
  • just got duped on MSO: Link to a heading in a Stack Overflow question/answer
    – starball
    Commented Aug 2, 2023 at 22:13

1 Answer 1

13
+50

One of the comments asked about clarification on why this should be implemented.

SE already has direct links to questions, answers, and comments, but after that, navigation gets fuzzy.

For small posts, this isn't a problem. It's easy to scroll down and find the relevant chunks of information. However, for the bigger ones, where there's lots of text, it's easy to miss parts, or it overall takes time finding the relevant description. For bigger posts, where the user might just be looking for one part of the post, this could also be used to add table of contents (manually - this isn't desired everywhere), or otherwise make jumping to the relevant part easier

The question itself mentions linking straight to a badge description in the badge list, but this can be applied further. One perfect example off the top of my head is the SEDE schema post. Because of the way it's written, it takes a lot of space, and text everywhere makes it hard to navigate.

If this feature request was implemented, users could copy links straight to i.e. ReviewTasks, and the post could get a built-in table of contents, making it easier to navigate when a specific part of that answer is needed elsewhere. This isn't the only post where that applies either. Essentially any of the massive posts, including those in the question, would benefit from direct linking.

I imagine one of the concerns is ID overlap - which is a perfectly valid concern. But if the ID is prepended with the post ID (for an instance, a link to the investor badge in the badge list would look like https://meta.stackexchange.com/questions/67397/#67399-investor).

A second reason it should be implemented is because even with headers standing out, when there are a lot of them, and a lot of text, it can still be easy to miss them. Especially if there's a mix of several headers (i.e. h1 with h2 and h3 nearby).

1
  • 3
    the main problem is that Common mark (the markdown version SE will end-up on) has not yet settled on how to markup fragment identifiers: talk.commonmark.org/t/anchors-in-markdown/247/32 and as such it isn't yet in the spec and when it does I hope they get it right so it will work on SE when each post starts using id's in the markdown.
    – rene Mod
    Commented May 19, 2019 at 16:01

You must log in to answer this question.

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