getzola/zola · error

Cannot merge config.toml with theme.toml because the followi

Error message

Cannot merge config.toml with theme.toml because the following values have incompatibles types:
- {}
 - {}

What it means

When a theme is used, Zola merges the theme's theme.toml values into the site's config as a fallback. This error is raised by the recursive `merge` function when it tries to merge a TOML table with a non-table value (or vice versa) at the same key, i.e. the theme.toml and config.toml define the same key with incompatible types.

Source

Thrown at components/config/src/config/mod.rs:444

            // These are not tables so we have nothing to merge
            Ok(())
        }
        (true, true) => {
            // Recursively merge these tables
            let into_table = into.as_table_mut().unwrap();
            for (key, val) in from.as_table().unwrap() {
                if !into_table.contains_key(key) {
                    // An entry was missing in the first table, insert it
                    into_table.insert(key.to_string(), val.clone());
                    continue;
                }
                // Two entries to compare, recurse
                merge(into_table.get_mut(key).unwrap(), val)?;
            }
            Ok(())
        }
        _ => {
            // Trying to merge a table with something else
            Err(anyhow!(
                "Cannot merge config.toml with theme.toml because the following values have incompatibles types:\n- {}\n - {}",
                into,
                from
            ))
        }
    }
}

impl Default for Config {
    fn default() -> Config {
        Config {
            base_url: DEFAULT_BASE_URL.to_string(),
            title: None,
            description: None,
            theme: None,
            default_language: "en".to_string(),
            languages: BTreeMap::new(),

View on GitHub (pinned to 61d3082821)

Solutions

  1. Open both config.toml and the theme's theme.toml, find the key present in both, and make their types match (both tables or both scalars)
  2. If you want to override an entire theme table, replace it with a table of the same shape rather than a single value
  3. Remove the conflicting key from your config.toml if you intend to inherit the theme's value

Example fix

// before (config.toml)
[extra]
author = "Jane"  # theme.toml has [extra.author] as a table with name/url
// after
[extra.author]
name = "Jane"
url = "https://example.com"
Defensive patterns

Strategy: validation

Validate before calling

// Compare value types at conflicting keys before merging
fn same_shape(a: &toml::Value, b: &toml::Value) -> bool {
    match (a, b) {
        (toml::Value::Table(ta), toml::Value::Table(tb)) =>
            ta.keys().all(|k| tb.get(k).map_or(true, |v| same_shape(&ta[k], v))),
        (toml::Value::Table(_), _) | (_, toml::Value::Table(_)) => false,
        _ => true,
    }
}

Type guard

fn both_tables_or_neither(a: &toml::Value, b: &toml::Value) -> bool {
    a.is_table() == b.is_table()
}

Try / catch

match add_theme_extra(&mut config, &theme) {
    Err(e) if e.to_string().contains("incompatibles types") => {
        eprintln!("Fix the key whose type differs between config.toml and theme.toml");
    }
    r => r?,
}

Prevention

When it happens

Trigger: Calling `merge` / `add_theme_extra` where a key exists as a table in one file and as a scalar/array in the other — e.g. `extra` (or any config section) is a table in theme.toml but the site's config.toml overrides the same key with a string, boolean, or array.

Common situations: Site config defines `extra.something` as a string while theme.toml defines `extra.something` as a table (or vice versa); overriding a whole theme `extra` subtree with a scalar; type changes after a Zola/theme upgrade.

Related errors


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