Custom CSS confusion #452
-
Thanks for the great theme! I am super new to Hugo, and so I'm sure I'm missing something obvious, but following the documentation on adding custom_css, I can't seem to get it to pick up anything. I created a "assets/ananke/css/custom.css" file, making a small change to the .cf style (text-align: justify), and added custom_css = ["custom.css"] under [params] in my site's config.toml. However, it doesn't seem to pick up even when I restart the Hugo server... is there some other missing step? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 16 replies
-
I have exactly the same question. In fact, I have more than once been at a los as to where to put things (images for example) because the description does not offer an example or spell out the full path to the expected location. Given a project directory of 'news', I have news/themes/ananke for ananke. Under news/themes/ananke I have, supplied with ananke, assets/ananke/css, that is, news/themes/ananke/assets/ananke/css, and in that final css directory are _code.css, _hugo-internal-templates.css, _social-icons.css, _styles.css and _tachyons.css. Putting custom.css in this directory and adding custom_css = ["custom.css"] does not include the contents in main.min.css. Ok, let's try creating news/assets/ananke/css/custom.css. No dice. Back to news/themes/ananke/assets/ananke/css. Change the name to _custom.css, and change the config to custom_css = ["_custom.css"]. Nothing doing. Here's the code from layouts/partials/func/style/GetMainCSS.html
I new to Hugo and go, but that looks sort of OK to me. But obviously it's not working for some reason. Could an expert tell me what's wrong? |
Beta Was this translation helpful? Give feedback.
-
To rebuild main.min.css, it seems that you must
I didn't have the extended version, and only discovered I needed it after deleting the _gen files above. When I then ran hugo the build failed telling me I needed the extended version. |
Beta Was this translation helpful? Give feedback.
-
Good to know. That seems a bit less than ideal to me though. I am bringing in the theme as a submodule and I don't want to be deleting and regenerating parts of it. My solution ended up being just making a root copy of site-style.html and just manually linking in my CSS. It isn't like it was very big or doing a lot, so the minification is pretty unimportant to me. |
Beta Was this translation helpful? Give feedback.
-
I'm a little confused as to why folks are having so much trouble with custom CSS. I import Ananke as a module (having made my site a Hugo module, per the docs): In theme = ["github.com/theNewDynamic/gohugo-theme-ananke"] In the custom_css = [ "custom-dfd.css" ] I have a file which contains: .presentation-pdf div {
overflow: auto;
resize: both;
}
.presentation-pdf div object {
border: 2px solid;
display: block;
height: 760px;
margin-right: .8em;
resize: both;
width: 100%;
}
@media (max-height: 499px) {
.presentation-pdf div object {
height: 100vh;
}
}
@media (max-height: 900px) {
.presentation-pdf div object {
height: 480px;
}
}
.intro-card-pdf-gallery {
display: inline-block;
margin-left: .8em;
margin-right: .8em;
margin-top: .3em;
text-align: center;
vertical-align: baseline;
}
.intro-card-pdf-gallery div {
height: 665px;
overflow: auto;
text-align: center;
width: 700px;
}
.intro-card-pdf-gallery object {
border: 2px solid;
display: block;
height: 100%;
margin-right: .8em;
width: 100%;
}
.nested-img img {
height: auto;
} and the CSS is properly included in minification and works for me. I always use the extended version of Hugo so I can't comment on whether the non-extended Hugo would work. It is not necessary to delete anything beforehand though (at least with up-to-date Hugo). Perhaps the issue the OP (@jpursey) is having is overriding a 'Tachyons` style. Mostly I've switched to Tachyon-izing my shortcodes and layouts so that I'm not modifying the CSS just adding (or removing) classes where appropriate. One final note, to override a particular layout in a theme it is not necessary to modify the theme, one only needs to copy the layout into the same location in your site For example I have a customized HTH If the OP is still having problems with the |
Beta Was this translation helpful? Give feedback.
-
It would make sense that we only use We could take a quick poll...
|
Beta Was this translation helpful? Give feedback.
To rebuild main.min.css, it seems that you must
I didn't have the extended version, and only discovered I needed it after deleting the _gen files above. When I then ran hugo the build failed telling me I needed the extended version.