# CLI flag to skip external links check

**URL:** <https://zola.discourse.group/t/cli-flag-to-skip-external-links-check/2427>\
**Category:** Feature requests\
**Created:** [December 28, 2024, 1:54pm UTC](https://zola.discourse.group/t/cli-flag-to-skip-external-links-check/2427 "2024-12-28T13:54:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nop\_thread](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/nop_thread/32/1381_2.png) [@nop\_thread](https://zola.discourse.group/u/nop_thread)\
**Post date:** [December 28, 2024, 1:54pm UTC](https://zola.discourse.group/t/cli-flag-to-skip-external-links-check/2427/1 "2024-12-28T13:54:12Z")

</div>

## 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](https://github.com/lo48576/zola/tree/feature/offline-check-flag) and seems to work as I expected.  
Diff is reasonably small.

---

<div class="post-metadata">

**Author:** ![keats](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@keats](https://zola.discourse.group/u/keats)\
**Post date:** [December 29, 2024, 4:34pm UTC](https://zola.discourse.group/t/cli-flag-to-skip-external-links-check/2427/2 "2024-12-29T16:34:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![nop\_thread](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/nop_thread/32/1381_2.png) [@nop\_thread](https://zola.discourse.group/u/nop_thread)\
**Post date:** [December 29, 2024, 5:39pm UTC](https://zola.discourse.group/t/cli-flag-to-skip-external-links-check/2427/3 "2024-12-29T17:39:38Z")

</div>

Then adding a new field to the config?

```toml
[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.

---

<div class="post-metadata">

**Author:** ![keats](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@keats](https://zola.discourse.group/u/keats)\
**Post date:** [December 30, 2024, 9:52am UTC](https://zola.discourse.group/t/cli-flag-to-skip-external-links-check/2427/4 "2024-12-30T09:52:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![nop\_thread](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/nop_thread/32/1381_2.png) [@nop\_thread](https://zola.discourse.group/u/nop_thread)\
**Post date:** [December 31, 2024, 1:17pm UTC](https://zola.discourse.group/t/cli-flag-to-skip-external-links-check/2427/5 "2024-12-31T13:17:54Z")

</div>

Submitted [pull request #2756](https://github.com/getzola/zola/pull/2756) with `--skip-external-links` CLI flag.
