Zola: External link checker does not find GitHub anchors

Created on 29 Sep 2019  路  6Comments  路  Source: getzola/zola

I just updated my blog_os project from zola 0.7.0 to zola 0.9.0. It worked great and it even caught several invalid anchors in internal links. Thanks a lot for your work!

I noticed a problem when checking external links using zola check: For some URLs (mostly GitHub URLs), it reports an anchor as 'not found' even though it seems to exist. Some examples:

Error: Dead link in /home/runner/work/blog_os/blog_os/blog/content/first-edition/extra/cross-compile-libcore.md to https://github.com/japaric/rust-cross#the-target-triple: Anchor `#the-target-triple` not found on page
Dead link in /home/runner/work/blog_os/blog_os/blog/content/first-edition/extra/cross-compile-libcore.md to https://github.com/japaric/xargo#dependencies: Anchor `#dependencies` not found on page
Dead link in /home/runner/work/blog_os/blog_os/blog/content/first-edition/extra/naked-exceptions/03-returning-from-exceptions/index.md to https://github.com/rust-lang/rust/blob/c772948b687488a087356cb91432425662e034b9/src/librustc_back/target/mod.rs#L194-L214: Anchor `#L194-L214` not found on page

I think the reason is that GitHub uses IDs like user-content-the-target-triple instead of the-target-triple for its generated anchors. I'm not sure why the anchor still works without the user-content prefix. Maybe it's done in Javascript. Either way, I think that it might be worth to handle somehow, given that GitHub is a common link target.

bug done

Most helpful comment

I'm leaning towards adding a configurable list of domains to not check for anchors. Eg a user could put

skip_anchors_checking = ["github.com", "caniuse.com"]

(temporary name). This way each user can select what they can to check or not.
At the same time, doing it at the domain level doesn't seem to be the best solution as https://help.github.com/en/articles/github-glossary#blame is a valid thing to check for.
Maybe URL prefixes instead of domains? Eg if url.starts_with(x), skip it

All 6 comments

I can confirm that GitHub line anchors are an issue and can add https://caniuse.com/#feat=css-filters to the list of false positives.

Oh that's definitely done with JavaScript for GH I think :( For caniuse, it's probably a SPA using hash-based navigation.

I'm not sure how to differentiate actual anchors and anything using JS...

I think an option to not check the anchors either:

  • entirely: somewhat more easy, but not that nice
  • for certain sites: more complicates, but would help the most, since users could just opt-out for pages like caniuse or github

would help a lot.

I'm leaning towards adding a configurable list of domains to not check for anchors. Eg a user could put

skip_anchors_checking = ["github.com", "caniuse.com"]

(temporary name). This way each user can select what they can to check or not.
At the same time, doing it at the domain level doesn't seem to be the best solution as https://help.github.com/en/articles/github-glossary#blame is a valid thing to check for.
Maybe URL prefixes instead of domains? Eg if url.starts_with(x), skip it

Maybe URL prefixes instead of domains?

Prefix with or without protocol? Because both https://help.github.com/en/articles/github-glossary#blame and http://help.github.com/en/articles/github-glossary#blame are valid (yes I know, you shouldn't use HTTP, but that's not the point here).

Another false positive: https://gchq.github.io/CyberChef/#recipe=To_Base64('A-Za-z0-9%2B/%3D')&input=aGVsbG8gd29ybGQ.
I vote for URL prefixes with protocol.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

RealOrangeOne picture RealOrangeOne  路  6Comments

timvisee picture timvisee  路  7Comments

codesections picture codesections  路  5Comments

phil-opp picture phil-opp  路  3Comments

florianb picture florianb  路  5Comments