Skip to content
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

Ability to extend theme CSS? #2124

Open
hsn10 opened this issue Mar 1, 2023 · 6 comments
Open

Ability to extend theme CSS? #2124

hsn10 opened this issue Mar 1, 2023 · 6 comments

Comments

@hsn10
Copy link

hsn10 commented Mar 1, 2023

Theme css can be overridden by creating CSS with same name. In most cases its better to extend CSS, not to replace it.

Natural way of extending CSS is to use @import theme.css from site SCSS file. I haven't find any way how to do it. Is this already implemented in some way? Can it be implemented and documented?

@import path like '/themes/name/file'

@magikstm
Copy link
Contributor

magikstm commented Mar 2, 2023

The use of @import depends on your use case and isn't always the best option.

You should be able to do what you want in the CSS file. You're free to set it up as you wish.

If the one you use is actually to be used "as-is" (from a 3rd-party or a known library), could you use a different CSS file and use ?

Ref: https://stackoverflow.com/questions/10036977/best-way-to-include-css-why-use-import

@hsn10
Copy link
Author

hsn10 commented Mar 2, 2023

To add additional CSS file to page I would need to modify theme page template. For easiest maintainability of my app, its best not to modify theme unless some functionality is missing.

I do not need to modify theme, just override few CSS definitions and I think that @import from theme + add mine styles is cleanest way to do it. Theme will not be modified - I will just git pull theme updates without conflicts.

@magikstm
Copy link
Contributor

magikstm commented Mar 3, 2023

You could:

  1. Add a <link> that defines these more specific CSS under that one in your theme
  2. Add a @import at the top of your main CSS file and just replace it with yours in your "static" folder

It doesn't seem to be an issue with Zola.

You're free to do what you want with your CSS files.

@hsn10
Copy link
Author

hsn10 commented Mar 3, 2023

This works:

https://zola.discourse.group/t/override-scss-from-theme/1066

It should be documented. Its seems to be frequently asked question for static site generators.

@hsn10
Copy link
Author

hsn10 commented Mar 4, 2023

  1. <LINK> needs to modify template which I would like to avoid
  2. Well, main CSS that's the problem. I have no main CSS because Theme is not providing "user include CSS" for overriding.

@cibyr
Copy link

cibyr commented May 21, 2023

Seems like this would work if the build steps were reordered so that sass rendering happens after static files (at least theme static files) are copied to the output directory. Would that break anything else? In my mental model, all theme processing should probably happen before any site processing, so that anything in the site can override anything in the theme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants