I'm trying to use Sphinx with Sphinx book theme in my documentation but I'm having problems building the docs.
I installed Sphinx and the theme and initiated the docs with:
pip install sphinx
pip install sphinx_book_theme
sphinx-quickstart
Then I changed the theme to Sphinx book theme as described in the docs by adding the extension and changing the HTML theme in the conf.py
.
My conf.py
looks like this (removed autogenerated comments):
# -- Project information -----------------------------------------------------
project = 'mytest'
copyright = '2022, Me'
author = 'Me'
release = '0.1.0'
# -- General configuration ---------------------------------------------------
extensions = [
'sphinx_book_theme' # I changed this
]
templates_path = ['_templates']
language = 'python'
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
# -- Options for HTML output -------------------------------------------------
html_theme = 'sphinx_book_theme' # I changed this
html_static_path = ['_static']
However, when I try to build the docs:
sphinx-build docs . _build/html
I get this error:
Running Sphinx v4.5.0
loading translations [python]... not available for built-in messages
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 1 source files that are out of date
updating environment: [new config] 1 added, 0 changed, 0 removed
reading sources... [100%] index
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] index
Theme error:
An error happened in rendering the page index.
Reason: TemplateNotFound('sidebar-logo.html')
How do I fix this and use the book theme? Do I need to create a sidebar template? If so, how and where? I don't have a logo for my project and would not like to create one at this moment.
I found the answer myself. It seems if you remove the line templates_path = ['_templates']
it works:
# -- Project information -----------------------------------------------------
project = 'mytest'
copyright = '2022, Me'
author = 'Me'
release = '0.1.0'
# -- General configuration ---------------------------------------------------
extensions = [
'sphinx_book_theme'
]
# templates_path = ['_templates'] # REMOVE THIS LINE TO WORK
language = 'python'
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
# -- Options for HTML output -------------------------------------------------
html_theme = 'sphinx_book_theme'
html_static_path = ['_static']
If you have something in the templates
, I suspect you need to create the sidebar-logo.html
here. Not sure how though.