HPY Tool Documentation

Static Assets

hpy-tool provides built-in support for handling static assets like CSS files, JavaScript files, images, fonts, and other resources that need to be served alongside your compiled HTML pages.

Enabling Static Asset Handling

To enable this feature, you must:

  1. Define the static_dir_name setting within the [tool.hpy] table in your hpy.toml file.
  2. Ensure the directory named by static_dir_name exists within your configured input_dir.

Example hpy.toml enabling static assets in src/static/:

[tool.hpy]
input_dir = "src"
output_dir = "dist"
# This line enables the feature for the directory named "static"
static_dir_name = "static"

If static_dir_name is commented out or not present in hpy.toml, static asset handling is disabled.

How it Works

When static asset handling is enabled:

Referencing Static Assets

When referencing static assets in your HTML (e.g., in `_layout.hpy` or page files) or CSS, use paths relative to the root of the output directory.

Since the static assets are copied into //, you typically reference them starting with //.

Examples (assuming static_dir_name = "static"):

The development server correctly serves these files from the output directory.

# Make sure this closing tag is aligned as needed