NHS.UK frontend jinja templates
A Jinja implementation of the NHS.UK frontend components.
NHS.UK frontend contains the code you need to start building user interfaces for NHS websites and services.
Installation
pip install nhsuk-frontend-jinja
Compatibility
The following table shows the version of NHS.UK frontend jinja that you should use for your targeted version of NHS.UK frontend:
| NHS.UK frontend version | NHS.UK frontend jinja version |
|---|---|
| 9.3.0 | 0.1.0 |
| 9.5.2 | 0.2.0 |
| 9.6.1 | 0.3.0 |
| 9.6.2 | 0.3.1 |
| 10.0.0 | 0.4.1 |
| 10.1.0 | 0.5.0 |
| 10.2.0 | 0.6.0 |
| 10.2.2 | 0.6.1 |
| 10.3.0 | 0.7.0 |
| 10.3.1 | 0.7.2 |
| 10.4.0 | 0.8.0 |
| 10.5.0 | 0.9.0 |
| 10.5.2 | 0.9.1 |
| 10.6.0 | 0.10.0 |
| 10.6.1 | 0.10.2 |
| 10.7.0 | 1.0.0 |
| 10.7.1 | 1.0.1 |
| 10.7.2 | 1.0.3 |
Configuration
Configure your Jinja environment to load templates from this package and use ChainableUndefined.
Flask example:
from jinja2 import FileSystemLoader, ChoiceLoader, PackageLoader, ChainableUndefined
app.jinja_options = {
"undefined": ChainableUndefined, # This is needed to prevent jinja from throwing an error when chained parameters are undefined
"loader": ChoiceLoader(
[
FileSystemLoader(PATH_TO_YOUR_TEMPLATES),
PackageLoader("nhsuk_frontend_jinja"),
]
),
"keep_trailing_newline": True,
"trim_blocks": True,
"lstrip_blocks": True,
"autoescape": True
}
app.jinja_env.policies["json.dumps_kwargs"] = {"sort_keys": False, "separators": (",", ":")}
Plain Jinja example:
from jinja2 import Environment, FileSystemLoader, ChoiceLoader, PackageLoader, ChainableUndefined
jinja_env = Environment(
undefined=ChainableUndefined,
loader=ChoiceLoader([
FileSystemLoader(PATH_TO_YOUR_TEMPLATES),
PackageLoader("nhsuk_frontend_jinja"),
]),
keep_trailing_newline=True,
trim_blocks=True,
lstrip_blocks=True,
autoescape=True,
)
jinja_env.policies["json.dumps_kwargs"] = {"sort_keys": False, "separators": (",", ":")}
Alternatively, if you want to reference components without the 'nhsuk/components' or 'nhsuk/macros' prefixes, you can include additional PackageLoaders that specify package_path:
ChoiceLoader([
FileSystemLoader(PATH_TO_YOUR_TEMPLATES),
PackageLoader("nhsuk_frontend_jinja", package_path="templates/nhsuk/components"),
PackageLoader("nhsuk_frontend_jinja", package_path="templates/nhsuk/macros"),
PackageLoader("nhsuk_frontend_jinja"),
])
You should then be able to extend the default page template:
{% extends 'nhsuk/template.jinja' %}
{% block pageTitle %}Example - NHS.UK Frontend{% endblock %}
{% block content %}
{% endblock %}
See Page Template in the service manual for details of all the options.
Usage
Visit the NHS digital service manual for examples of components and guidance for when to use them.
All our macros take identical arguments to the Nunjucks ones, except you need to quote the parameter names.
{% from 'nhsuk/warning-callout/macro.jinja' import warningCallout %}
{{ warningCallout({
"heading": "Quotey McQuoteface",
"HTML": "<p>Don't forget to quote your parameter names!</p>"
}) }}
Note that all macro paths use the .jinja extension.
Contribute
Read our contributing guidelines to contribute to NHS.UK frontend jinja.
Development environment
Get in touch
This repo is maintained by NHS England. Open a GitHub issue if you need to get in touch.
Licence
The codebase is released under the MIT Licence, unless stated otherwise. This covers both the codebase and any sample code in the documentation. The documentation is © NHS England and available under the terms of the Open Government 3.0 licence.
Metadata
Release files for nhsuk-frontend-jinja 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nhsuk_frontend_jinja-1.0.3.tar.gz | 122.0 kB | With provenance | Details for nhsuk_frontend_jinja-1.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nhsuk_frontend_jinja-1.0.3-py3-none-any.whl | Python 3 | none | any | Details for nhsuk_frontend_jinja-1.0.3-py3-none-any.whl |
Total release size: 213.4 kB
Release files / nhsuk_frontend_jinja-1.0.3.tar.gz
| Download URL | nhsuk_frontend_jinja-1.0.3.tar.gz |
|---|---|
| Size | 122.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ef2ff62bb8223bd1e2a7336bf4b767f19f52e406c324d8e49de555df4c94596e
|
|
BLAKE2b-256 checksum How to use checksums |
26d5721d31a8b8b30dc0dd41d1ba30e8a389a9ca16bc1e2198eff409e7878a24
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.
Transparency logRelease files / nhsuk_frontend_jinja-1.0.3-py3-none-any.whl
| Download URL | nhsuk_frontend_jinja-1.0.3-py3-none-any.whl |
|---|---|
| Size | 91.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4f9a8fb1f617c40ce1c90729cac37725c241467598775dd29c922a26046404ca
|
|
BLAKE2b-256 checksum How to use checksums |
a176dad10005ec4da9cec07061d91dbe130d92b3f5f0a268d05de560ec6a1d2d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.
Transparency logSecurity for nhsuk-frontend-jinja 1.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for nhsuk_frontend_jinja-1.0.3.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.