When running with check_external_links, it should also check whether the given anchor targets are present. That is, when I link
https://test.com/page#link
Zola should check that the page
https://test.com/page exists and <a id="link"> tag That's a bit trickier as we are rendering markdown concurrently and anchors are generated while rendering. It would have to be done in a post-rendering phase somehow
I have it locally but it relies on Zola being aware of all the anchors obviously and it won't parse HTML links for anchors (at least for now). You are defining them like so:
### <a name="data_structures"></a> Data Structures
which would have to change to
### Data Structures {#data_stuctures}
since named anchors is also coming for Zola 0.8. What do you think?
For internal links this is perfect, I didn't know of the {#data_stuctures} syntax, but it's nicer than injecting <a name>.
Long term, having the ability to check for external anchors (e.g., from shortcode-templated HTML to external HTML) would still be nice.
For internal links this is perfect, I didn't know of the {#data_stuctures} syntax, but it's nicer than injecting .
It's still only in the next branch, that's why :p
The only question left is whether this check should be by default or only inzola check...
Since we can't catch every anchors, it could fail valid sites since there's no way to turn it off. I do wonder if having links to anchors generated in shortcodes or raw HTML in the markdown is common enough though
How would default checking work with serve during development?
I'd be fine having build only do build stuff and focus on speed, with an option check_on_build that can be enabled. Then check can do more expensive checks by default (again, probably with TOML options for better control), which can be run before deployment.
Anchor checking is done after the markdown for all pages is rendered (since we need that info to know their ToC). I don't think it would cause a noticeable slowdown like the external links, it's pretty much just creating one path from a string + some hashmaps lookup. Nothing like a HTTP request.
At the same time, since Zola does check internal links by default, I think it makes sense to check the anchors by default as well in build/serve...
I don't know if you've seen it but there is a new command in the upcoming version zola check that does all the verification without actually writing anything to disk. This is the new way to check for external links validity, rather than an option in the config.
At the same time, since Zola does check internal links by default, I think it makes sense to check the anchors by default as well in build/serve...
Ah, in that case yes, I agree.
I don't know if you've seen it but there is a new command in the upcoming version zola check that does all the verification without actually writing anything to disk.
I've seen some comments. I actually wanted to check the next branch out this morning but unfortunately I'm getting build errors (in sass-sys on Windows). As soon as a new release is available, I'd love to try it and upgrade.
in sass-sys on Windows
The pain everyone on Windows seems to encounter :(
@Keats I noticed this was closed without resolution and also labeled as an enhancement. Would you be open to accepting a PR to add the feature?
I'm still learning, but I went ahead and implemented it on a branch wyze:feature/check_external_link_anchors and curious if I could send over a PR for it.
Having something like this would still be very helpful for the Rust cheat sheet.
Just the other day @wyze found a target that was dead for some time, and I'm sure we have quite a few more ...
That looks good, a few comments but can be done on the PR
Hi, I've seen the PR seems to have been merged; if I try 0.9, would the target-checker work?
Yes, although some issues persist: https://github.com/getzola/zola/issues/805
I just realized that I have been using the #target checker for several weeks now, and it has been incredibly helpful finding moved pages we link to in the Rust Cheat Sheet. Thank you so much for implementing this @wyze and @Keats!
Most helpful comment
I just realized that I have been using the
#targetchecker for several weeks now, and it has been incredibly helpful finding moved pages we link to in the Rust Cheat Sheet. Thank you so much for implementing this @wyze and @Keats!