WordPress.org

Make WordPress Core

Opened 6 years ago

Last modified 3 weeks ago

#25927 reopened feature request

Remove the theme information from style.css and add a theme manifest file

Reported by: jolyonruss Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.7.1
Component: Themes Keywords: 2nd-opinion
Focuses: Cc:

Description

Currently the metadata related to a theme is store in a comment at the top of style.css.

I argue this is not a clean separation of concerns, yes .css files can contain semantic information to help the reader navigate the file, but using it to store metadata is bad practice.

I propose creating a theme manifest file that sits at the root of the theme directory and contains all the metadata related to the theme that's currently at the top of style.css, things like the name, author, etc. but it could also contain a file list for the theme with a few lines about the files usage.

Externalising the metadata and adding more contextual information will greatly improve developers ability to hack on top of others themes and understand their rationale for certain decisions.

Change History (10)

#1 @ocean90
6 years ago

#25928 was marked as a duplicate.

#2 @ocean90
6 years ago

Related: #24152

#3 @nacin
6 years ago

As said in #24152: "the current headers are a very integral part of WordPress and are one of those things that make things so simple to so many."

#4 @wonderboymusic
6 years ago

*cough* package.json *cough*

#5 @nacin
6 years ago

As said in #24152: "While JSON files are both machine-readable and human-readable, they aren't necessarily human-editable. You need to understand syntax and such, and there are some gotchas like trailing commas and when to quote that can be confusing. I think this would be a nice thing to keep in our back pocket in case the world of dependencies, testing, and such force something more powerful than the existing headers. But the current headers are a very integral part of WordPress and are one of those things that make things so simple to so many."

At this time, the limited benefit does not outweigh the high cost and increased barrier to entry.

#6 @nacin
5 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to maybelater
  • Status changed from new to closed

#7 follow-up: @atomicjack
4 years ago

  • Keywords 2nd-opinion added
  • Resolution maybelater deleted
  • Status changed from closed to reopened

I think this definitely needs to be looked into for the modern web.

SASS is being used more-and-more, as is Composer, Grunt, etc.

Currently, if you're using a mixture of these tools and frameworks, you will usually compile and minify your CSS on the fly, which removes 'comments', thus breaking the style.css. So instead, a manifest file for storing the theme information, or even just a theme-config.php, would be ideal.

#8 @SergeyBiryukov
4 years ago

  • Milestone set to Awaiting Review

This ticket was mentioned in Slack in #core by atomicjack. View the logs.


4 years ago

#10 in reply to: ↑ 7 @helen
4 years ago

Replying to atomicjack:

Currently, if you're using a mixture of these tools and frameworks, you will usually compile and minify your CSS on the fly, which removes 'comments', thus breaking the style.css. So instead, a manifest file for storing the theme information, or even just a theme-config.php, would be ideal.

FWIW, this is being done successfully already, typically via one of two methods:

  • The root style.css file serves only as a manifest and is never actually enqueued. The compressed stylesheet is located elsewhere (e.g. within /assets/css/ and enqueued from there. I am not opining on continuing to use a CSS file for this kind of info, but this is essentially the same result.
  • The theme information comment in style.css is notated in a way that the compiling/minifying routine won't strip. Sass does not strip /* */ comments, and clean-css (the most commonly used minifier as far as I know) keeps "loud" comments, which work just fine for theme info: /*! */.
Note: See TracTickets for help on using tickets.