So I am developing a wordpress theme using a series of LESS files for the CSS. These compile using codekit to a combined and minifed stylesheet that I use for the theme’s styling.
I understand a wordpress theme must have a style.css which includes the info about the theme in its comments, but is it required to link this style.css in the header.php? Surely I can just have the theme info in it and nothing else and leave it untouched in the theme folder.
The stylesheet I actually use can just be called styles.css or main.css or something.
can anyone confirm this or give reasons why this might be a bad idea?
I would say: you should not use the
style.css
for the actual production CSS.The reason is simple: minification. You cannot minify the content of the file completely, because WordPress has to read it. In my themes, I use
style.css
just for the headers, and I add a comment, explaining where to find the real CSS, so other developers donât have to search too long.Example:
You are correct, Harry, that you do not need to actually call to or load the default
style.css
in your header file. Since I’ve been using SCSS in my themes, I’ve encountered this same issue, but had decided to maintain the link tostyle.css
for the following reasons which may or may not be applicable to your situation:style.css
exists and is in use, and I don’t want to thwart that assumption with respect to plugins. I don’t know if/when this would be an issue and would be interested to hear others’ experiences and advice on this point.style.css
active and available gives my users a way to still be able to make CSS changes from the WP admin.style.css
without affecting my ability to continue to use my SCSS files.Again, these points may not be applicable to your situation but have informed my decision to keep the default
style.css
linked, even if it’s mostly blank except for the required theme info.Yes, WordPress uses the theme’s
style.css
as a “config” document.You are also correct, as far as I can tell, that you don’t have to actually load
style.css
on the front end in order to have it serve its “config” purposes.What you are doing should be fine. I am pretty sure I have seen other themes do something similar but I can’t swear to it. The only issue I can see would be if some plugin erroneously assumes that
style.css
is the (only) stylesheet in the theme.You could also add this to your
config.rb
(if you’re using Compass) and CodeKit will automatically copy your minified stylesheet tostyle.css
in the theme root.I use this with every WordPress theme I develop and it works like a charm.
Make sure that the comment in your
style.scss
file starts with the!
after the opening comment or else it will be removed in the minification:Source: CSS-Tricks