getzola/zola · error

zola.toml (or config.toml) not found in current directory or

Error message

zola.toml (or config.toml) not found in current directory or ancestors, current_dir is {}

What it means

With no explicit --config, get_config_file_path searches the current directory and all ancestors for zola.toml (preferred) then legacy config.toml. If neither is found anywhere up the tree, it reports this error and exits with code 1 — Zola cannot determine the site root.

Source

Thrown at src/main.rs:48

                    ),
                );
                std::process::exit(1);
            });
            (root, path.to_path_buf())
        }
        None => {
            // Try zola.toml first, then fall back to config.toml
            let zola_config = Path::new("zola.toml");
            let legacy_config = Path::new("config.toml");

            if let Some(root) = dir.ancestors().find(|a| a.join(zola_config).exists()) {
                (root, zola_config.to_path_buf())
            } else if let Some(root) = dir.ancestors().find(|a| a.join(legacy_config).exists()) {
                (root, legacy_config.to_path_buf())
            } else {
                messages::unravel_errors(
                    "",
                    &anyhow!(
                        "zola.toml (or config.toml) not found in current directory or ancestors, current_dir is {}",
                        dir.display()
                    ),
                );
                std::process::exit(1);
            }
        }
    };

    // if we got here we found root_dir so config file should exist so we could theoretically unwrap safely
    let config_file_uncanonicalized = root_dir.join(&config_path);
    let config_file = config_file_uncanonicalized.canonicalize().unwrap_or_else(|e| {
        messages::unravel_errors(
            &format!("Could not find canonical path of {}", config_file_uncanonicalized.display()),
            &e.into(),
        );
        std::process::exit(1);
    });

View on GitHub (pinned to 61d3082821)

Solutions

  1. cd into the root of your Zola site (the directory containing zola.toml or config.toml) and re-run the command
  2. Create a site with `zola init my-site` if you haven't got one yet
  3. Add a zola.toml (or legacy config.toml) to the project root if it was accidentally deleted or renamed
  4. Confirm the file name spelling — Zola looks for exactly `zola.toml` or `config.toml`, not variants

Example fix

// before
/home/user $ zola build
// zola.toml (or config.toml) not found...
// after
/home/user $ cd ~/sites/my-blog
/home/user/sites/my-blog $ zola build
Defensive patterns

Strategy: validation

Validate before calling

// shell: confirm we're in a Zola site before running commands
if [ ! -f zola.toml ] && [ ! -f config.toml ]; then
  echo "Not a Zola site root (no zola.toml/config.toml)"; exit 1
fi
zola build

Try / catch

// shell
cd "$(git rev-parse --show-toplevel)" && zola build || echo "No zola.toml/config.toml at repo root — run zola init"

Prevention

When it happens

Trigger: Running zola build/serve/check outside any Zola site directory and outside all of its parent directories — e.g. from $HOME, a freshly cloned repo that hasn't been created with `zola init`, or a directory where the config was renamed/deleted.

Common situations: Opening a terminal in the wrong project directory; a project where config.toml was deleted or renamed; initializing CI before `zola init`; supporting legacy config.toml only on old Zola versions while the project expects the new name.

Understand the failure class

Background: "Config file not found": what it means and how to fix it in docker-sync, Maven, Vagrant, Turborepo and other tools — this error's family across 60 libraries.

Related errors


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