Thanks to https://github.com/pytest-dev/pytest/issues/11988#issuecomment-1950318888, the problem was our custom template. The solution was to copy the template from Sphinx 7 and remove the header.
Ref: #6402