Use custom theme on ReadTheDocs

2019-07-25 19:08发布

问题:

I try to use a custom theme inherited from Sphinx's built-in ReadTheDocs Theme.

When I use it on my local computer I have the good design. But when I am on the read the doc version (imported from github) there is no CSS.

Did I miss something?

The repo with the branch using the custom theme: https://github.com/DigitalSkills-fr/Docs/tree/custom_theme/docs

The doc on RTD with the targeted branch: http://digitalskills-docs.readthedocs.io/fr/custom_theme/index.html

Thanks for any help.

回答1:

You should specify only built-in theme names in your conf.py.

# The theme to use for HTML and HTML Help pages.  See the documentation for
# a list of builtin themes.
#html_theme = 'default'
html_theme = 'theme_digitalskills'

Delete your custom entry and restore the original to:

html_theme = 'default'

Assuming you have modified the CSS files in your branch custom_theme, then RTD should copy all the files within the list of directories specified in html_static_path, overriding the built-in theme's CSS files:

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']