# עוגנים לא עובדים על פוסטים בתוך נושא

**URL:** https://meta.discourse.org/t/anchors-not-working-across-posts-within-topic/240512
**Category:** Bug
**Created:** [30 בספטמבר,‏ 2022,‏ 7:48pm UTC](https://meta.discourse.org/t/anchors-not-working-across-posts-within-topic/240512 "2022-09-30T19:48:00Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![orangeandblack5](https://avatars.discourse-cdn.com/v4/letter/o/edb3f5/32.png) [@orangeandblack5](https://meta.discourse.org/u/orangeandblack5)
#### Post date: [30 בספטמבר,‏ 2022,‏ 7:48pm UTC](https://meta.discourse.org/t/anchors-not-working-across-posts-within-topic/240512/1 "2022-09-30T19:48:00Z")

</div>

We’re trying to set up a topic as a sort of FAQ/forum usage guide, and in doing so we’d like to have a number of longer posts, each with a number of headings, and compile a table of contents in the first post of the topic so users can easily jump around.

This is proving deceptively difficult to make work as intended and digging around Meta isn’t really helping, unfortunately. We’re aware of the plugin-thingy (auto-ToC or whatever it’s called), but we just want this for one singular topic and so don’t really want to deal with that.

We’ve tried using the link icons next to an auto-generated markdown header via the # symbols, but that isn’t working - we’re not sure if this is just because of the colors we’re using for the headers, or something else entirely, but in any case this works for some but not all of our headers.

Trying to use HTML tags with manual ids for our headers had no success either - this just wasn’t jumping to the links at all. We saw somewhere on Meta that the id information was being stripped out by Discourse and stopped pursing this approach.

We then saw a clever idea using empty links placed right above our headers that you could just jump to, and although this at first seemed to work after we get a few posts down it also stops jumping to the correct place in the linked post.

Does anybody know why headers seem to be so broken, and how we can make them work across multiple posts within a single topic? I’m classifying this as a bug, because the behavior seems incredibly undesirable, but I’d be okay jumping through some hoops on our end to get this working if anybody knows how.

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [30 בספטמבר,‏ 2022,‏ 7:57pm UTC](https://meta.discourse.org/t/anchors-not-working-across-posts-within-topic/240512/2 "2022-09-30T19:57:06Z")

</div>

For anchors to work across longer topics you would need to use the full post address with the header appended to compensate for the target post not being loaded on the screen.

If the anchor was `<a name="anchor"></a>` in the OP of this topic, using this link would work even in post eg 456

`https://meta.discourse.org/t/anchors-not-working-across-posts-within-topic/240512/1#anchor`

Does that help?

---

<div class="post-metadata">

### Author: ![orangeandblack5](https://avatars.discourse-cdn.com/v4/letter/o/edb3f5/32.png) [@orangeandblack5](https://meta.discourse.org/u/orangeandblack5)
#### Post date: [1 באוקטובר,‏ 2022,‏ 5:25pm UTC](https://meta.discourse.org/t/anchors-not-working-across-posts-within-topic/240512/3 "2022-10-01T17:25:47Z")

</div>

That is what we were already doing, unfortunately

Our links in the ToC were of this format:

`https://www.site.com/t/topic-name/ABCD/E#header--header-name`

and our actual links in the posts were of this format

`<a name="header--header-name"></a>`

Worked for the first few posts, broke around post 8 or 9.

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [1 באוקטובר,‏ 2022,‏ 5:34pm UTC](https://meta.discourse.org/t/anchors-not-working-across-posts-within-topic/240512/4 "2022-10-01T17:34:48Z")

</div>

I use this method on another site and it works really well for me. Have you got a link you could share so I can see it in action?

---

<div class="post-metadata">

### Author: ![orangeandblack5](https://avatars.discourse-cdn.com/v4/letter/o/edb3f5/32.png) [@orangeandblack5](https://meta.discourse.org/u/orangeandblack5)
#### Post date: [1 באוקטובר,‏ 2022,‏ 5:45pm UTC](https://meta.discourse.org/t/anchors-not-working-across-posts-within-topic/240512/6 "2022-10-01T17:45:10Z")

</div>

No, unfortunately, because the post is still restricted to staff-only.

Maybe I could try to replicate our setup on the theme creator website and see if it works there?

Update: Theme creator has no DIscourse BBCode, so I’m not convinced it’ll be perfectly 1:1. Unfortunate.

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [1 באוקטובר,‏ 2022,‏ 5:46pm UTC](https://meta.discourse.org/t/anchors-not-working-across-posts-within-topic/240512/7 "2022-10-01T17:46:03Z")

</div>

We tend to use [try.discourse.org](http://try.discourse.org) for these, but it may be more effort than it’s worth in this case?

The only thing that looks different than the ones I use is the double hyphen, but that seems a long shot. Perhaps it’s the amount of header links? I’m not sure.

---

<div class="post-metadata">

### Author: ![orangeandblack5](https://avatars.discourse-cdn.com/v4/letter/o/edb3f5/32.png) [@orangeandblack5](https://meta.discourse.org/u/orangeandblack5)
#### Post date: [1 באוקטובר,‏ 2022,‏ 5:47pm UTC](https://meta.discourse.org/t/anchors-not-working-across-posts-within-topic/240512/8 "2022-10-01T17:47:13Z")

</div>

> [@JammyDodger](#):
>
> Perhaps it’s the amount of header links?

That’s what I suspect, and why this is classified under #Contribute > Bug and not #Support.

I forgot about try, might move over

---

<div class="post-metadata">

### Author: ![orangeandblack5](https://avatars.discourse-cdn.com/v4/letter/o/edb3f5/32.png) [@orangeandblack5](https://meta.discourse.org/u/orangeandblack5)
#### Post date: [1 באוקטובר,‏ 2022,‏ 6:06pm UTC](https://meta.discourse.org/t/anchors-not-working-across-posts-within-topic/240512/11 "2022-10-01T18:06:24Z")

</div>

Got 'em

Reproducible on Try

[https://try.discourse.org/t/testing-heading-links-i-guess/1405?u=orangeandblack5](https://try.discourse.org/t/testing-heading-links-i-guess/1405?u=orangeandblack5)

The first few sets of anchor links work

The anchors for the last three posts do not

Sorry to push this out on a weekend

When do things on try get wiped, generally? Would prefer to not have to rebuild that entire set of anchor links again lol

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [1 באוקטובר,‏ 2022,‏ 6:10pm UTC](https://meta.discourse.org/t/anchors-not-working-across-posts-within-topic/240512/12 "2022-10-01T18:10:15Z")

</div>

They work for me the first time, and on a page refresh, but don’t when I use the navigation timeline to return to the OP.

I have ‘go back’ links in my similar posts with the full post address of the OP/TOC headers in, which would perform a page refresh. Would that work for you?

---

<div class="post-metadata">

### Author: ![orangeandblack5](https://avatars.discourse-cdn.com/v4/letter/o/edb3f5/32.png) [@orangeandblack5](https://meta.discourse.org/u/orangeandblack5)
#### Post date: [1 באוקטובר,‏ 2022,‏ 6:15pm UTC](https://meta.discourse.org/t/anchors-not-working-across-posts-within-topic/240512/15 "2022-10-01T18:15:15Z")

</div>

I mean, we could certainly use that as a stopgap

Because you are right, that does indeed work

However, nobody navigates like that normally, so I definitely think this is a pretty clear-cut bug and ideally should be patched when the team has time to get around to it

* * *

Actually we’ll probably just only link to the top-level posts, and add in the specific section anchors when it’s been fixed

Seems better than a broken feature for our users

* * *

Is there any way to save this post on Try from getting wiped so somebody who knows more about Discouse than I do can poke around to figure out why this is happening?

Or would I be better off to recreate it here?

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [1 באוקטובר,‏ 2022,‏ 6:23pm UTC](https://meta.discourse.org/t/anchors-not-working-across-posts-within-topic/240512/16 "2022-10-01T18:23:58Z")

</div>

You could open those posts up in edit mode or grab the `raw` version and copy them over to a topic on your site as a more permanent example to link to (or to save them and recreate them on try again at a later point).

---

<div class="post-metadata">

### Author: ![orangeandblack5](https://avatars.discourse-cdn.com/v4/letter/o/edb3f5/32.png) [@orangeandblack5](https://meta.discourse.org/u/orangeandblack5)
#### Post date: [1 באוקטובר,‏ 2022,‏ 6:29pm UTC](https://meta.discourse.org/t/anchors-not-working-across-posts-within-topic/240512/17 "2022-10-01T18:29:28Z")

</div>

eh I’ll just do it here

[https://meta.discourse.org/t/example-anchor-links-dont-work-unless-page-reloaded/240589?u=orangeandblack5](https://meta.discourse.org/t/example-anchor-links-dont-work-unless-page-reloaded/240589)

this way there’s no chance of something on our site messing with the team’s ability to fix the issue
