Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
1  
You should leave the style.css with theme infos at the root of your theme folder. That's it. –  JMau Aug 22 '13 at 16:37

4 Answers 4

up vote 9 down vote accepted

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:

/*
Theme Name:    My theme name
Version:       2013.08.24
License:       MIT
Text Domain:   t5_theme
Domain Path:  /lang

You will find the real stylesheet in css/default.css.
*/
share|improve this answer
2  
This is nice idea. –  Ravs Aug 24 '13 at 22:58
    
This is what I do as well, works like a charm. –  Dalton Aug 27 '13 at 20:49
    
Wow, one of those things I can't believe I didn't think of doing. Awesome idea @toscho. –  Andrew Bartel Sep 5 '13 at 23:15

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.

share|improve this answer

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 to style.css for the following reasons which may or may not be applicable to your situation:

  • Default WP assumptions are that 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.
  • If my actual in-use stylesheet is in a folder, it prevents users from being able to edit the site's CSS. Keeping style.css active and available gives my users a way to still be able to make CSS changes from the WP admin.
  • Related, while working on the staging site with other partners, if they don't also use SCSS, they can make changes to 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.

share|improve this answer

You could also add this to your config.rb (if you're using Compass) and CodeKit will automatically copy your minified stylesheet to style.css in the theme root.

require 'fileutils'
on_stylesheet_saved do |file|
  if File.exists?(file) && File.basename(file) == "style.css"
    puts "Moving: #{file}"
    FileUtils.mv(file, File.dirname(file) + "/../" + File.basename(file))
  end
end

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:

/*!
  Theme Name: Your Theme

Source: CSS-Tricks

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.