Skip to main content

GOV.UK Tech Docs Sphinx Theme

A Sphinx theme to replicate the GOV.UK Tech Docs Template.

Where this documentation refers to the root folder we mean where this README.md is located.

Getting started

The source code for this Sphinx theme is available at https://github.com/ukgovdatascience/govuk-tech-docs-sphinx-theme. You can use this for your own Sphinx documentation by following the steps below.

Install the package

The latest released version can be installed from the Python Package Index (PyPI):

pip install govuk-tech-docs-sphinx-theme

Amend your Sphinx conf.py configuration file

To use this Sphinx theme, modify your Sphinx conf.py configuration file as follows:

  1. Add the theme in the list of extensions:
    extensions = ["govuk_tech_docs_sphinx_theme"]
    
  2. Make sure the author, and project variables reflect your organisation name, and project
  3. Set html_theme = "govuk_tech_docs_sphinx_theme"
  4. Set the html_context dictionary as follows:
    html_context = {
        "github_url": None,                  # if using GitHub, set to the URL of your repository as a string
        "gitlab_url": None,                  # if using GitLab, set to the URL of your repository as a string
        "conf_py_path": "docs/",             # assuming your Sphinx folder is called `docs`
        "version": "main",                   # assuming `main` is your repository's default branch
        "accessibility": "accessibility.md"  # assuming your accessibility statement is at `docs/accessibility.md`
    }
    
  5. Set the html_theme_options dictionary as follows:
    html_theme_options = {
        "organisation": "",  # replace with your organisation's abbreviation (ideally) or name - long text may not look nice
        "phase": ""          # replace with an Agile project phase - see https://www.gov.uk/service-manual/agile-delivery
    }
    

Note, not all Sphinx configuration settings are currently supported by this theme — feel free to contribute to support other settings!

Add an accessibility statement

With the Sphinx autodoc extension, you may find headers do not fit the content that
follows. This [fails the WCAG 2.1 success criterion 2.4.6 Headings and
Labels][wcag-2.1-2.4.6].

To resolve this, copy the entire `docs/_template` folder from this repository into
your Sphinx folder, and ensure your `conf.py` file contains:

```python
templates_path = ["_templates"]
```

All public sector bodies have to meet the 2018 accessibility regulations unless exempt.

To add an accessibility statement, create a blank Markdown file in the root of your Sphinx folder called accessibility.md. This folder is the same location as your Sphinx conf.py configuration file. Add the following header to your new Markdown file:

---
orphan: true
---
# Accessibility statement

followed by your accesibility statement. Guidance on how to write an accessibility statement can be found on GOV.UK.

Next, in your Sphinx conf.py file, check that the html_context variable has this file referenced, i.e.:

html_context = {
    ...,
    "accessibility": "accessibility.md",
    ...
}

Apply the theme's components

This theme should be compatible with most ReStructuredText syntax, and also includes components from the GOV.UK Design System. See the example components page for further details.

If you are using MyST to build Sphinx documentation using Markdown, see the equivalent Markdown components page.

Troubleshooting

If you have difficulties with this theme, please raise an issue or contact us to report a problem.

Licence

Unless stated otherwise, the codebase is released under the MIT License. This covers both the codebase and any sample code in the documentation. Additional third-party component licences are stated in the LICENSE file. The documentation is © Crown copyright and available under the terms of the Open Government 3.0 licence.

Contributing

If you want to help us build, and improve govuk-tech-docs-sphinx-theme, view our contributing guidelines.

Acknowledgements

This project structure is based on the govcookiecutter template project.

Metadata

Release files for govuk-tech-docs-sphinx-theme 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for govuk-tech-docs-sphinx-theme 1.0.0
File Size Uploaded Provenance Actions
govuk-tech-docs-sphinx-theme-1.0.0.tar.gz 299.6 kB Without provenance Details for govuk-tech-docs-sphinx-theme-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for govuk-tech-docs-sphinx-theme 1.0.0
File Interpreter ABI Platform Actions
govuk_tech_docs_sphinx_theme-1.0.0-py3-none-any.whl Python 3 none any Details for govuk_tech_docs_sphinx_theme-1.0.0-py3-none-any.whl

Total release size: 615.3 kB

Release files / govuk-tech-docs-sphinx-theme-1.0.0.tar.gz

Download URL govuk-tech-docs-sphinx-theme-1.0.0.tar.gz
Size 299.6 kB
Tags Source
SHA-256 checksum
How to use checksums
5e227aa18d40767ca8a04c70106a8df667b2f8ed348f167aed2832fd98240275
BLAKE2b-256 checksum
How to use checksums
56477e1fc78f90a24a5e35f1109ca5f0a2815e3fd6a4e11b0a64ea6918ac639c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.6 CPython/3.9.5 Linux/5.8.0-1036-azure

Release files / govuk_tech_docs_sphinx_theme-1.0.0-py3-none-any.whl

Download URL govuk_tech_docs_sphinx_theme-1.0.0-py3-none-any.whl
Size 315.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b4f3cdeac81de401403b91c02b3c2062c06eb0254f78d3567518f54ccbdf0279
BLAKE2b-256 checksum
How to use checksums
a6d458531baa0db4e318db6a4bb0771e082eb12e5f11648675bd07963c46a642
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.6 CPython/3.9.5 Linux/5.8.0-1036-azure

Security for govuk-tech-docs-sphinx-theme 1.0.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A 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.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page