Skip to content

Conversation

theaminuli
Copy link

What?

Automatically enqueue style.css when creating a blank theme with the Create Block Theme (CBT) plugin.

Why?

Currently, when a blank theme is created, an empty style.css file is added, but adding CSS to it does not take effect until a functions.php file is added to enqueue the stylesheet. This creates confusion for users who want to work directly in the editor or prefer using style.css instead of the Additional CSS area. Automatically enqueuing style.css ensures that the stylesheet works out-of-the-box for those who want to use it.

Fixes / Reference
Fixes #334

How to test:

  1. Install and activate the updated Create Block Theme plugin.
  2. In the WP Admin, go to Appearance → Create Block Theme → Create Blank Theme.
  3. Confirm that a new blank theme is generated.
  4. Open the generated theme folder and check:
    • A functions.php file exists.
    • It contains enqueue code for style.css.
  5. Add some simple CSS to style.css, for example:
body {
  background: pink;
}

  1. Activate the new blank theme.
  2. Visit the site’s frontend — the background should reflect your CSS changes (confirming that style.css is enqueued).
  3. Optional: Inspect the source in the browser dev tools → check that style.css is being loaded.

@iqbal-xs
Copy link

iqbal-xs commented Sep 7, 2025

@theaminuli, @t-hamano PR looks good

@t-hamano
Copy link
Contributor

t-hamano commented Sep 7, 2025

@theaminuli thanks for the PR!

Personally, I'm not sure if loading styles in a particular way is the best way, and I think we should discuss this a bit more before moving forward with this PR.

@pbking
Copy link
Contributor

pbking commented Sep 15, 2025

Personally in my themes I usually load my styles from an asset other than the style.css file. (It feels weird keeping the metadata in an asset that I compile from SCSS and doing something like /styles/index.scss > /assets/css/index.css is what I do.

While it would be handy to have that setup for me for my CBT created theme that doesn't feel appropriate. There's a ton of other ways an opinions on how/where those styles should be loaded. If you need those loaded I feel like you're taking the created theme beyond "basic" and "universal" which is what I think is where CBT should be landing. (RE: As opinion-less as possible)

Just my 0.02 since the reality is that I nearly always start with my own starter theme with all the things setup the way I like and just duplicate that instead of creating a blank one.

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

Successfully merging this pull request may close these issues.

Automatically enqueue style.css when creating a blank theme
4 participants