create-block-theme
create-block-theme copied to clipboard
Automatically enqueue style.css when creating a blank theme
Pulling in feedback from the FSE Outreach program's Build A Block Theme exploration:
There is an empty style sheet added when a blank theme is created with CBT plugin. But adding CSS to it doesn’t work until a functions.php is added to enqueue it. I think that style.css should automatically be enqueued or that a functions.php with the enqueue should be included. I am trying to use only the editor, but think that if the stylesheet is there, it should be usable.
How can we explain to users that the Stylesheet is used because it is required to provide WordPress with information about the theme, like the theme name and version, not to add CSS? Add a comment to the file?
Ohh I see. Thanks for clarifying -- limits of my lack of knowledge with themes. I think a comment is a great idea and approach.
In a way I agree that "if it is there it should work", but in this case it can't be removed even if it is otherwise empty.
I also think that if the person knows that the theme needs a functions.php and knows the css file needs to be enqueud, its not too difficult for them to add it.
So is it more beneficial to:
- enqueu it "in case anyone wants to use it" Or,
- not include a file that is not used by default (functions.php), and not enqueu a file that is not used by default (style.css)
This came up again with a user in the forum: https://wordpress.org/support/topic/create-a-child-theme-for-twenty-twenty-three/
So is it more beneficial to:
- enqueu it "in case anyone wants to use it" Or,
- not include a file that is not used by default (functions.php), and not enqueu a file that is not used by default (style.css)
I agree very much with @carolinan that it would be much less confusing for users to go with either of these two options.
I would prefer to use a style.css file than the Additional CSS area in the FSE block editor. The Additional CSS UI and accessibility is dreadful. I find it much simpler to use a style.css file, but to have to enqueue it yourself? Led me down a rabbit hole that I'm finally climbing out of.
Just ran into this issue and it definitely needs some love.
I agree. Style.css file for me as well. Definitely should be enqueued already, even if it's not used. It will be there for those who want to.