getzola/zola · error

could not parse domain `{}` from link: `{}`

Error message

could not parse domain `{}` from link: `{}`

What it means

This is the parse-failure branch of `get_link_domain`: `Url::parse(link)` returned an Err (e.g. relative URL without a base), and the function bails embedding both the link and the underlying url-crate error. Called from `check_external_links` while validating external links.

Source

Thrown at components/site/src/link_checking.rs:124

    }
    messages
}

fn should_skip_by_prefix(link: &str, skip_prefixes: &[String]) -> bool {
    skip_prefixes.iter().any(|prefix| link.starts_with(prefix))
}

fn should_skip_by_file(file_path: &Path, glob_set: &GlobSet) -> bool {
    glob_set.is_match(file_path)
}

fn get_link_domain(link: &str) -> Result<String> {
    match Url::parse(link) {
        Ok(url) => match url.host_str().map(String::from) {
            Some(domain_str) => Ok(domain_str),
            None => bail!("could not parse domain `{}` from link", link),
        },
        Err(err) => bail!("could not parse domain `{}` from link: `{}`", link, err),
    }
}

/// Checks all external links and returns all the errors that were encountered.
/// Empty vec == all good
pub fn check_external_links(site: &Site) -> Vec<String> {
    struct LinkDef {
        file_path: PathBuf,
        external_link: String,
        domain: String,
    }

    impl LinkDef {
        pub fn new(file_path: &Path, external_link: &str, domain: String) -> Self {
            Self {
                file_path: file_path.to_path_buf(),
                external_link: external_link.to_string(),
                domain,

View on GitHub (pinned to 61d3082821)

Solutions

  1. Fix the link in the content so it is a fully-qualified absolute URL including scheme
  2. Pre-validate links with `Url::parse` and skip/flag relative links before calling this function
  3. Inspect the embedded url-crate error (`RelativeUrlWithoutBase` most commonly) to identify the malformation

Example fix

// before
[example.com](example.com)
// after
[example.com](https://example.com)
Defensive patterns

Strategy: validation

Validate before calling

fn is_parseable_url(link: &str) -> bool { Url::parse(link).is_ok() }

Type guard

fn as_url(link: &str) -> Option<Url> { Url::parse(link).ok() }

Try / catch

match get_link_domain(link) {
    Ok(d) => check(d),
    Err(e) => link_errors.push(format!("fix href: {e}")),
}

Prevention

When it happens

Trigger: `get_link_domain` is called with a string that is not an absolute URL — missing scheme (`example.com/page`), malformed characters, or any input the `url` crate's parser rejects.

Common situations: Markdown/HTML content with bare domains without `http://`, typos in hrefs, templating that concatenates paths where a full URL was expected.

Related errors


AI-assisted analysis of getzola/zola@61d3082821 (2026-09-03). Data as JSON: /api/errors/afe68243eb1d789c. Report an issue: GitHub.