Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add anchors to reference section headers #1747

Closed
colearendt opened this issue Aug 10, 2021 · 4 comments · Fixed by #1779
Closed

Add anchors to reference section headers #1747

colearendt opened this issue Aug 10, 2021 · 4 comments · Fixed by #1779
Labels
feature a feature request or enhancement front end 🌷 General HTML, CSS, and JS issues reference 📚

Comments

@colearendt
Copy link

colearendt commented Aug 10, 2021

This is most important to me on the "Reference" section headers, i.e. here: https://pkgdown.r-lib.org/reference/index.html

There may be other places, though. In the Changelog?

This is done automatically on the "README," for instance: https://pkgdown.r-lib.org/#in-the-wild

@klmr
Copy link
Contributor

klmr commented Aug 16, 2021

You can already link to these headers, since they all have IDs. For instance, in the first link you’ve posted the section headers have the ID section-‹header slug›, e.g. https://pkgdown.r-lib.org/reference/index.html#section-templates.

It’s just that, for some reasons, the “anchor link” image isn’t displayed next to the headers on hover specifically on the Reference page. For other pkgdown websites (but not the current ‘pkgdown’ website proper), some other pages (such as vignettes and the “Changelog” page) also don’t show anchor link images next to section headers. In those cases that’s due to <h2> elements not carrying a class="hasAnchor" attribute.

@colearendt
Copy link
Author

colearendt commented Aug 16, 2021

Thanks for the clarification - that's a great distinction. Would it be possible to include such "anchor link" images? Is that something easily customizable by a user? Happy to rephrase my issue to be mostly about that, if it would be helpful! It greatly simplifies linking to things quickly 😄

@maelle
Copy link
Collaborator

maelle commented Aug 27, 2021

That would be a feature request. At the moment anchors are added by pkgdown to the NEWS page and to pages produced from R Markdown.

At the moment in the index pages like the reference index one can use the TOC on the right to find the direct link to sections.

@maelle maelle added feature a feature request or enhancement front end 🌷 General HTML, CSS, and JS issues labels Aug 27, 2021
@hadley hadley changed the title Automatic "header" links to deep-link to sections Add anchors to reference section headers Sep 21, 2021
@hadley
Copy link
Member

hadley commented Sep 22, 2021

(@colearendt for future reference these are called anchor links)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement front end 🌷 General HTML, CSS, and JS issues reference 📚
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants