-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
add_css_file adds file twice. #9267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'm having the same problem with for filename, attrs in self.app.registry.js_files:
self.add_js_file(filename, **attrs) Since The workaround for now is to call |
I found the reason. CSS/JS files added at |
Regardless of the discussed error, I think it is not good to rely on There might be a better way to do this (please let me know!), but I've done it like this: https://github.com/mgeier/insipid-sphinx-theme/blob/3336d6b50f5a7c7d18e6efc3a974c4b2e2cc3a60/src/insipid_sphinx_theme/insipid/layout.html#L50-L56 This way, it is not necessary to install the theme as an extension. |
@mgeier I am not installing my theme as an extension. The only change in my conf.py is to set the value of Furthermore, the official documentation recommends |
Yes, it is one of the officially recommended ways to install JS files. It helps to distribute the HTML theme as a python package. |
Did you read what I said upthread? |
Hmm? What do you mean? |
The recommend method is broken. |
Yes. The goal of this issue is to fix it. |
Fix #9267: html theme: CSS and JS files added by theme were loaded twice
Describe the bug
While playing at building a theme, I noticed that when I use
sphinx.application.Sphinx.add_css_file
, the file gets added twice in the generated HTML.To Reproduce
Steps to reproduce the behavior:
Create a new theme and setup it with the following setup function
add also the theme conf file:
The whether or not I'm using
add_css_file("basic.css")
, the generatedHTML/_static
folder containsmytheme.css
basic.css
in either case.
With
add_css_file("basic.css")
, the HTML<head>
looks like (comment added for emphasis on duplicatedlink
tag)Without
add_css_file("basic.css")
, the_stagic/basic.css
link
tag is added 0 times.Expected behavior
I am not sure was would be the expected behavior. Should the parent theme CSS always be added implicitely? I am not sure. But having it linked twice seams weird to me.
The text was updated successfully, but these errors were encountered: