CLI flag to skip external links check

Summary

Add a CLI flag to skip internet access on zola check.

For example, if you run zola check --offline then it checks the site except for the external links availability.

Description

In some situations, users may want frequent checks but infrequent external links check.

  • If a site contains so many external links or links to heavy servers, the check may take long time.
  • If a user zola check frequently (e.g., hooking filesystem access or CI for every commits), they would want zola to skip external links check for such frequent runs, but eventually they will run external links check before publishing the site.

zola check --offline (or something like --ignore-external-links?) will be useful to support such use cases, and users can run checks more frequently without risks and costs.

Alternatives

Config file

skip_prefixes = ['http://', 'https://'] in [link_checker] section of config.toml may let zola check ignore the external links, but this requires file modification. This is not simple as --offline flag, and automated edit could be difficult if the field already have some values.

Flag name

I prefer --offline as it is simple and clear, but people might prefer more verbose names?

PoC

Implemented a patch https://github.com/lo48576/zola/tree/feature/offline-check-flag and seems to work as I expected.
Diff is reasonably small.

1 Like

I think it would be better to have something like --check-external-links that defaults to true

Then adding a new field to the config?

[link_checker]
# Boolean, true by default.
# `--check-external-links` will make this true temporarily.
check_external_links = true

It sounds reasonable to make external links check opt-in (if users hope so), however, true by default will make one-time skip a bit tedious because it requires config modification.

Additionally adding --no-check-external-links will solve the issue, but is it acceptable to add two CLI flags for one feature? I don’t find such pair of flags in the current zola.

Probably not a config field field. Maybe as you said originally then, just a flag like --skip-external-links

1 Like

Submitted pull request #2756 with --skip-external-links CLI flag.