This directory contains Jinja2 templates used by the build script to generate HTML pages for the marimo WebAssembly + GitHub Pages project. Templates define the structure and appearance of the generated pages, particularly the index page that lists all notebooks and apps.
A template should be a valid HTML file with Jinja2 syntax for dynamic content. The template should:
- Have a
.html.j2extension - Include proper HTML structure (doctype, head, body)
- Use responsive design principles for good display on various devices
Templates receive the following variables from the build script:
-
notebooks: A list of dictionaries containing information about notebooks- Each notebook has:
display_name: The formatted name of the notebook (e.g., "Penguins" instead of "penguins")html_path: The path to the HTML file for the notebook
- Each notebook has:
-
apps: A list of dictionaries containing information about apps- Each app has:
display_name: The formatted name of the apphtml_path: The path to the HTML file for the app
- Each app has:
A complete template should include:
-
Conditional Notebook Section: Only display if notebooks exist
{% if notebooks %} <h2>Notebooks</h2> <div class="notebooks-container"> {% for notebook in notebooks %} <div class="notebook-item"> <h3>{{ notebook.display_name }}</h3> <a href="{{ notebook.html_path }}">Open Notebook</a> </div> {% endfor %} </div> {% endif %}
-
Conditional App Section: Only display if apps exist
{% if apps %} <h2>Apps</h2> <div class="apps-container"> {% for app in apps %} <div class="app-item"> <h3>{{ app.display_name }}</h3> <a href="{{ app.html_path }}">Open App</a> </div> {% endfor %} </div> {% endif %}
To use a custom template with the build script, use the --template parameter:
uv run .github/scripts/build.py --output-dir _site --template templates/your-custom-template.html.j2This repository includes three example templates:
index.html.j2: A less lean template with more styling and a footertailwind.html.j2: A minimal and lean template using Tailwind CSS
- Styling:
- Include CSS directly in the template using
<style>tags for simplicity, or - Use Tailwind CSS via CDN for a utility-first approach without custom CSS
- Include CSS directly in the template using
- Responsive Design: Ensure the template works well on different screen sizes
- Conditional Sections: Use
{% if %}blocks to conditionally display sections based on data availability - Comments: Include comments in your template to explain complex sections
- Accessibility: Use semantic HTML and proper ARIA attributes for accessibility