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

Linkchecker doesn't report on broken anchor links #466

Open
ahouseholder opened this issue Feb 14, 2024 · 0 comments
Open

Linkchecker doesn't report on broken anchor links #466

ahouseholder opened this issue Feb 14, 2024 · 0 comments
Labels
enhancement New feature or request environment Project environment, deployment, CI, etc.

Comments

@ahouseholder
Copy link
Contributor

ahouseholder commented Feb 14, 2024

This only becomes an issue once we merge

(and it's a smaller issue than not having a linkchecker at all, so we can fix this one separately)

The linkchecker tool we're using (https://linkchecker.github.io/linkchecker/index.html) is sufficient to detect broken internal links within the site. I.e., it will fail/report an error when a file contains a link [foo](bar.md) and bar.md does not exist. This is adequate for our initial need.

However, linkchecker does not by default detect when an anchor link (one containing a #anchor) is broken.

So while [foo](bar.md#baz) will report an error if bar.md does not exist, it does not detect when bar.md exists but contains no anchor baz.

Similarly, even intra-page links won't fail on bad anchor names. E.g., [foo](#foo) does not fail when the file we're in has no foo anchor.

In general, we probably should just avoid to the degree possible using anchor links in this way, as unless we take specific care to explicitly include <a name=anchorname></a> tags in the markdown, the default is that anchors are just header names with non-word characters replaced by -, so ## My section heading becomes #my-section-heading. But because section headings are content, we can expect them to change based on editorial requirements, which has the side effect of potentially breaking anything that was linked to #my-section-heading when the heading changes to ## My New Section Heading with a new default anchor of #my-new-section-heading.

However, as it seems likely that at least intra-page links might have their place regardless of the above, we ought to be on the lookout for a linkchecker that can do this task for us and either replace the existing one with one that can do both page links and anchor links or augment the existing checker with one that does anchor links specifically.

@ahouseholder ahouseholder added enhancement New feature or request environment Project environment, deployment, CI, etc. labels Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request environment Project environment, deployment, CI, etc.
Projects
None yet
Development

No branches or pull requests

1 participant