Zola Missing Template Directory When Deploying from GitHub

Zola Missing Template Directory When Deploying from GitHub

If you’re using the Rust package (Zola)[https://www.getzola.org/] to build a static site, you might encounter an error about the templates directory being absent:

    Error: Failed to build the site
    Error: Error parsing templates from the /templates directory
    Error: Reason: Io error while writing rendered value to output: NotFound
    Error: Reason: The system cannot find the file specified. (os error 2)

This error occurs when the templates directory is missing. This was the case for me when I was using everything from a theme and had no templates of my own. The folder was there locally, but I found that my deployments over GitHub Actions was failing with that error.

Zola will error without this directory even if you aren’t trying to use anything from it, resulting in these Io error and NotFound errors.

Git Is The Problem

When a directory is empty, git will ignore it. Only directories with files are synced. To solve this issue, you can add a blank .gitkeep file to the templates directory. The .gitkeep file isn’t special to Git in any way, it’s just a convention used by the community.

From your Zola project folder, just run the following:

touch templates/.gitkeep
git add templates
git commit -m "Add .gitkeep file to templates directory"
git push