What is the URL of the page with the issue?

https://pkg.go.dev/google.golang.org/grpc#EmptyDialOption

What is your user agent?

Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36

Screenshot

Original: Golang x/pkgsite: type header table of contents links to a different type

After clicking "Experimental": Golang x/pkgsite: type header table of contents links to a different type

What did you do?

Under the "EmptyDialOption" type, I clicked on the "Experimental" link, which is intended to be a table of contents for the headers within the type doc.

What did you expect to see?

I expected the page to jump to the "Experimental" header just a few lines below (shown in the "Original" screenshot above).

What did you see instead?

The page jumped to https://pkg.go.dev/google.golang.org/grpc#hdr-Experimental, which is part of "func ClientSupportedCompressors" instead of "type EmptyDialOption".

The problem seems to be that the IDs (#hdr-Experimental) aren't unique per type/function, so links go to whichever appears first on the page.

Comment From: hyangah

@jba Isn't this an issue in go/doc/comment? (I see the same issue in godoc). Or does pkgsite use a custom header generation logic?

Comment From: gopherbot

Change https://go.dev/cl/573595 mentions this issue: internal/godoc/dochtml/internal/render: ensure unique heading ids