Project Structure
Understand Balzac’s directory structure and default configuration.
Default Structure
Section titled “Default Structure”A typical Balzac project looks like this:
my-site/├── balzac.toml # Configuration file├── dist/ # Generated output (created by balzac)├── pages/ # Handlebars templates for pages│ ├── index.hbs│ └── posts/│ └── details.hbs├── partials/ # Handlebars partials (optional)│ └── header.hbs├── layouts/ # Handlebars layouts (optional)│ └── main.hbs├── assets/ # Static files (optional)│ ├── style.css│ └── logo.svg└── content/ # Markdown content (optional) └── posts/ ├── first-post.md └── second-post.mdRequired Directories
Section titled “Required Directories”pages/
Section titled “pages/”The only required directory. Contains Handlebars templates that become your static pages.
pages/index.hbs:
<!DOCTYPE html><html> <body> <h1>Hello, World!</h1> </body></html>Output: dist/index.html
Created automatically by Balzac. Contains the generated static site. Do not manually edit this directory.
Optional Directories
Section titled “Optional Directories”content/
Section titled “content/”Store markdown content for collections. Each subdirectory becomes a collection.
content/├── posts/│ ├── hello-world.md│ └── about-me.md└── docs/ ├── getting-started.md └── advanced-topics.mdEach markdown file needs a corresponding template in pages/<collection>/details.hbs.
partials/
Section titled “partials/”Reusable template snippets that can be included in other templates.
partials/header.hbs:
<header> <h1>{{site_name}}</h1></header>Use in templates:
{{> header}}layouts/
Section titled “layouts/”Reusable page layouts that wrap content.
layouts/main.hbs:
<!DOCTYPE html><html> <head> <title>{{title}}</title> </head> <body> {{> header}} {{{body}}} {{> footer}} </body></html>assets/
Section titled “assets/”Static files copied directly to the output directory.
assets/├── style.css → dist/assets/style.css├── logo.svg → dist/assets/logo.svg└── favicon.ico → dist/assets/favicon.icoAccess in HTML:
<link rel="stylesheet" href="/assets/style.css">Configuration File
Section titled “Configuration File”balzac.toml
Section titled “balzac.toml”The main configuration file in your project root.
[global]site_name = "My Site"
[hooks]build_before = "pnpm build"
[bundler.vite]enabled = truemanifest_path = "dist/.vite/manifest.json"See Configuration Reference for all options.
File Naming Conventions
Section titled “File Naming Conventions”Handlebars files in pages/:
index.hbs→dist/index.htmlabout.hbs→dist/about.htmlcontact.hbs→dist/contact.html
Collections
Section titled “Collections”Markdown files in content/<collection>/:
content/posts/hello-world.md→dist/posts/hello-world.htmlcontent/posts/my-first-post.md→dist/posts/my-first-post.html
Templates
Section titled “Templates”Collection templates must be named details.hbs:
pages/posts/details.hbs- Template for thepostscollectionpages/docs/details.hbs- Template for thedocscollection
Custom Directory Structure
Section titled “Custom Directory Structure”You can customize directory names in balzac.toml:
output_directory = "./build"pages_directory = "./templates"layouts_directory = "./src/layouts"partials_directory = "./src/partials"assets_directory = "./static"content_directory = "./markdown"Minimal Project
Section titled “Minimal Project”The smallest possible Balzac project:
minimal/├── balzac.toml└── pages/ └── index.hbsbalzac.toml:
# Empty configuration uses all defaultspages/index.hbs:
<h1>Hello, World!</h1>Example: Blog Site Structure
Section titled “Example: Blog Site Structure”blog/├── balzac.toml├── pages/│ ├── index.hbs # Home page with post list│ ├── about.hbs # About page│ └── posts/│ └── details.hbs # Individual post template├── partials/│ ├── header.hbs│ ├── footer.hbs│ └── post-card.hbs├── layouts/│ └── default.hbs├── assets/│ ├── style.css│ └── logo.svg└── content/ └── posts/ ├── first-post.md └── second-post.mdExample: Documentation Site Structure
Section titled “Example: Documentation Site Structure”docs/├── balzac.toml├── pages/│ ├── index.hbs # Landing page│ └── docs/│ └── details.hbs # Doc page template├── partials/│ ├── sidebar.hbs│ ├── header.hbs│ └── footer.hbs├── assets/│ ├── theme.css│ └── logo.svg└── content/ └── docs/ ├── getting-started.md ├── installation.md └── configuration.mdBest Practices
Section titled “Best Practices”- Organize by purpose - Group files logically (pages, assets, content)
- Use consistent naming - lowercase with hyphens for files
- Keep it simple - Start with minimal structure, add as needed
- Separate concerns - Templates in
pages/, content incontent/, assets inassets/ - Use partials - Reuse common elements (header, footer, navigation)