# Template Structure and Conventions - Public Web Frontend **Last Updated:** November 18, 2025 --- ## Overview This document outlines the template structure, naming conventions, and best practices for Jinja2 templates in the Code of Conquest web frontend. **Template Philosophy:** - Clean, semantic HTML - Separation of concerns (templates, styles, scripts) - Reusable components via includes and macros - Responsive design patterns - Accessibility-first --- ## Directory Structure ``` templates/ ├── base.html # Base template (all pages extend this) ├── errors/ # Error pages │ ├── 404.html │ ├── 500.html │ └── 403.html ├── auth/ # Authentication pages │ ├── login.html │ ├── register.html │ └── forgot_password.html ├── dashboard/ # User dashboard │ └── index.html ├── characters/ # Character management │ ├── list.html │ ├── create.html │ ├── view.html │ └── edit.html ├── sessions/ # Game sessions │ ├── create.html │ ├── active.html │ ├── history.html │ └── view.html ├── multiplayer/ # Multiplayer sessions │ ├── create.html │ ├── lobby.html │ ├── session.html │ └── complete.html ├── partials/ # Reusable partial templates │ ├── navigation.html │ ├── footer.html │ ├── character_card.html │ ├── combat_ui.html │ └── session_summary.html ├── components/ # Reusable UI components (macros) │ ├── forms.html │ ├── buttons.html │ ├── alerts.html │ └── modals.html └── macros/ # Jinja2 macros ├── form_fields.html └── ui_elements.html ``` --- ## Base Template **File:** `templates/base.html` ```html
Welcome, {{ user.username }}!
{% else %} Login {% endif %} ``` ### Loops ```htmlLevel {{ character.level }} {{ character.player_class.name }}
No characters found. Create one?
{% endfor %}{{ character.player_class.name }}
HP: {{ character.current_hp }}/{{ character.max_hp }} | Gold: {{ character.gold }}