How to add custom css file to Sphinx?

ole picture ole · May 5, 2014 · Viewed 13.6k times · Source

How I can add custom css file? The following config does not work for me:

# conf.py
html_static_path = ['_static']
html_theme = 'default'
html_theme_options = {
  'cssfiles': ['_static/style.css']
}

Result:

C:\temp\test-docs\docs>make html
Running Sphinx v1.2.2
loading pickled environment... not yet created
building [html]: targets for 2 source files that are out of date
updating environment: 2 added, 0 changed, 0 removed
reading sources... [ 50%] help
reading sources... [100%] index

looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents...
Theme error:
unsupported theme option 'cssfiles' given

Answer

Gringo Suave picture Gringo Suave · Jun 23, 2016

A simpler way is to add this to your conf.py:

def setup(app):
    app.add_css_file('css/custom.css')  # may also be an URL

Then put the file into the _static/css/ folder.