Template Architecture
The Document Download Frontend uses Jinja2 templating with GOV.UK Frontend components to create accessible, government-standard user interfaces.Base Template
Document Download Template
File:app/templates/document_download_template.html
Purpose: Base template extended by all pages
Extends: govuk_frontend_jinja/template.html
Key Features:
Head Icons
Stylesheets and Meta Tags
referrer policy to "never" to prevent leaking document URLs
Page Title
Header
Content Structure
Footer
govukFooterWithoutExternalLinks instead of standard footer
Scripts
View Templates
Landing Page
File:app/templates/views/landing.html
Route: /d/<service_id>/<document_id>
Purpose: Initial page shown when user accesses document link
service_name: Name of sending servicecontinue_url: Next step URL (email confirmation or download)service_contact_info: Support contactcontact_info_type:"link","email", or"phone"
Email Confirmation Page
File:app/templates/views/confirm-email-address.html
Route: /d/<service_id>/<document_id>/confirm-email-address
Purpose: Email verification before allowing download
- Error prefix: Adds
"Error: "to page title when validation fails - Error summary: Displays all form errors at top of page
- CSRF protection: Includes CSRF token field
- Novalidate: Uses
novalidateto prevent browser validation (server-side only)
form: EmailAddressForm instanceservice_name: Sending service nameservice_contact_info: Support contactcontact_info_type: Contact method type
Download Page
File:app/templates/views/download.html
Route: /d/<service_id>/<document_id>/download
Purpose: Display file information and download link
Template Variables:
download_link: Pre-signed S3 URL for direct downloadfile_size: Formatted size (e.g., “2.5 MB”)file_type: Formatted type (e.g., “PDF”)service_name: Sending serviceservice_contact_info: Support contactcontact_info_type: Contact typefile_expiry_date: When file expires (optional)
File Unavailable Page
File:app/templates/views/file-unavailable.html
Purpose: Error page for 404/410 errors on document access
Template Variables:
status_code: HTTP status code (404 or 410)service_name: Sending service nameservice_contact_info: Support contactcontact_info_type: Contact method
Error Templates
Standardized error pages inapp/templates/error/:
- 400.html - Bad Request
- 401.html - Unauthorized
- 403.html - Forbidden
- 404.html - Not Found
- 410.html - Gone (expired documents)
- 429.html - Too Many Requests (rate limiting)
- 500.html - Internal Server Error
Rate Limit Error (429)
File:app/templates/error/429.html
Template Variables:
go_back_link: URL to return to (usually the form page)page_name: Context of where error occurred
Component Templates
GOV.UK Input Component
File:app/templates/components/govuk_input.html
Purpose: Wrapper for GOV.UK Design System input component
Custom Footer
File:app/templates/components/footer/macro.html
Macro: govukFooterWithoutExternalLinks
Purpose: Footer without external navigation links (simplified version)
Macros
Error Summary Macro
File:app/templates/macros/error_summary.html
Macro: render_error_summary(form)
Purpose: Render GOV.UK error summary component for form errors
Usage:
- Form-level errors (
form.form_errors) - Field-level errors from form validation
GOV.UK Frontend Integration
Components Used
Fromgovuk_frontend_jinja package:
- govukButton - Primary action buttons
- govukHeader - Standard GOV.UK header
- govukInput - Text input fields
- govukFooter - Page footer (customized)
Design System
Follows GOV.UK Design System standards:- Accessible HTML5 semantics
- Consistent spacing using utility classes
- Mobile-first responsive design
- WCAG 2.1 AAA compliance
Utility Classes
Common GOV.UK CSS utility classes:Asset Pipeline
Assets loaded viaasset_url() helper:
- Cache busting via manifest file
- CDN URL prefixing in production
- Local development paths
Security Features
Content Security Policy
Templates use CSP nonce for inline scripts:Referrer Policy
Prevents document URLs from leaking:Link Security
External links userel="noreferrer":
Template Inheritance
Inheritance hierarchy:per_page_title- Page-specific titlemain_content- Main content areacontent- Full content block (when custom layout needed)