Linking to portions of a post

Is there any way to link to a specific subportion of a large post? At first I attempted to specify an HTML name for an element and reference it [like so](#name). However, discourse (rightly) automatically strips name and id attributes from elements. As a side note, I’m not entirely sure that it would work anyway, as clicking anchor links of that style appears to redirect to the homepage.

The reason I would want to do this is that I am somewhat stretching the intended use for discourse by running a Nomic game on it. This game features a very long post with many rules with detailed descriptions, which will be edited and expanded as the game progresses. It would be very useful if I were able to insert a link to a specific rule when discussing it, rather than quoting the rule, which can become very cumbersome when discussing the interaction between multiple rules.


You could break up the rules into sections and put each section in its own post. Then you can link to a specific post when you need to call out a rule. Since the rules can change, maybe reserve the first 7-10 posts for rules expansion.

1 Like

It’s a serviceable solution, although I am somewhat uncomfortable with the enforced number of sections that would cause. Perhaps a separate rules topic would work, but I’d still prefer the named elements solution. I will experiment and report back.

I noticed that GitHub automatically adds deep links for each heading in content. That could make sense but it is kind of a rare use case. I suggest doing what @BhaelOchon recommended first.

I’ve compromised by creating a topic explicitly for holding rules, and making each rule its own reply. There are some nice side effects to that, such as being able to see posts where a rule has been invoked or referenced.

I would love the automatic header deep links, but I understand why that would be a low priority feature. Might make it a plugin myself if it bothers me enough.

1 Like

It’s also doesn’t make sense as what defines a “heading” in Discourse? While Markdown is fully supported (so you could do # Part 1) I think it’s such a rare and unlikely to be used feature.

However, adding ids to headers makes a lot of sense if once wiki posts are supported.

I don’t understand where ambiguity could exist on that subject, headings would be defined as h1-h6 surely?

Seems that this is still missing(?)

Idea: perhaps renderer could just assign a slug generated from contents to each header (h1-h6)?


# this is a title

should render as a named anchor:

<a name="this-is-a-title"><h1>this is a title</h1></a>

one could then link to its location directly:

[jump to local anchor](#this-is-a-title)
1 Like

This functionality is planned for the next release.


Came here looking for this. (Sorry to be that guy reviving an old thread.) Did it ever go out with 1.5? Because I can’t find any instance of “deep linking” or “headings” in those release notes. Is there a way to link directly to headings yet?

It’s still listed in the upcoming features for 1.6, which has a planned release date of August. So we can hope to see it some time between now and then.


Looks like this (headings getting id=‘something’ for anchor support) never happened? Is it still on a list somewhere or dropped?

Anchors are indeed supported! Check out the howto here: Deep Linking to Headings (Anchors)