Backport changes from sphinx_theme