Try: Define the minimum boilerplate code for a block-based theme#81
Try: Define the minimum boilerplate code for a block-based theme#81
Conversation
| @@ -0,0 +1,79 @@ | |||
| /* | |||
There was a problem hiding this comment.
This entire file could hopefully be dequeued and deleted once Gutenberg provides front-end alignments. WordPress/gutenberg#26633
| "units": [ "px", "em", "rem", "vh", "vw" ] | ||
| } | ||
| }, | ||
| "custom": { |
There was a problem hiding this comment.
These custom rules are only used in the alignments stylesheet above, so if that is removed, these could be removed too.
blockbase/functions.php
Outdated
| <?php | ||
|
|
||
| if ( ! function_exists( 'blockbase_support' ) ) : | ||
| function blockbase_support() { |
There was a problem hiding this comment.
Many of these settings should either be activated by default for block-based themes, or available as theme.json options:
add_theme_support( 'align-wide' );
add_theme_support( 'wp-block-styles' );
add_theme_support( 'responsive-embeds' );
add_theme_support( 'experimental-link-color' );
There was a problem hiding this comment.
Is there an issue for this in Gutenberg?
There was a problem hiding this comment.
I just opened WordPress/gutenberg#26901 to discuss.
blockbase/functions.php
Outdated
| /** | ||
| * Enqueue scripts and styles. | ||
| */ | ||
| function blockbase_scripts() { |
There was a problem hiding this comment.
Just thinking out loud... if we can eliminate the add_theme_support calls above, this file would only exist to enqueue the stylesheets. Would it be possible to enqueue the stylesheets from within theme.json instead?
There was a problem hiding this comment.
I've opened an issue here to discuss: WordPress/gutenberg#26902
| @@ -0,0 +1,15 @@ | |||
| /* | |||
| Theme Name: Empty Theme | |||
There was a problem hiding this comment.
I was thinking the same. That would be nice.
There was a problem hiding this comment.
The theme directory (and core as well) would need, what I assume, to be a pretty sizable overhaul to do away with the need to have any stylesheet.
There was a problem hiding this comment.
Yeah, currently core detects themes from their style.css file. So if we want to allow these to be inside the theme.json file, a patch would have to be submitted to core at the same time so that these can be properly used.
I agree though, the stylesheet will in many cases be just a just file used to define the theme.
There was a problem hiding this comment.
I guess as theme.json involves we should allow just a theme.json theme. But this change would touch many parts of our code and is not something essential. Also as we are I guess most themes will still need at least some lines of CSS code. But once theme.json expands having theme information there seems like a good path.
|
We've been testing this PR this morning and found that featured images are not enabled by default 😃 We could add The docs say:
But I tried to set global.settings.post.thumbnails = true on the json and it did nothing. I probably did it wrong. |
|
Thanks! I don't think this option exists yet for For now, I've added the traditional |
jorgefilipecosta
left a comment
There was a problem hiding this comment.
Should we also include a simple homepage template that lists the posts as part of the minimum boilerplate?
Yeah, we could — We'd technically need both an Without any templates, the theme doesn't technically work by default. So it probably makes sense to add in that baseline at least. I've added them in 2c6d4e1. |
primenest
left a comment
There was a problem hiding this comment.
what would the emptytheme/assets/block-template-parts file be used for?
As of the last commit, that folder contains a reusable header template part. This is used at the top of the |
|
@kjellr Do you know if the plans to make the FSE HTML files into PHP files should be reflected here yet? |
Not yet — this PR reflects the current state, not a planned future state. |
jffng
left a comment
There was a problem hiding this comment.
emptytheme/assets/block-template-parts is an empty file that I think was accidentally created and checked in?
| @@ -0,0 +1,9 @@ | |||
| <!-- wp:template-part {"slug":"header","theme":"emptytheme","tagName":"header"} /--> | |||
There was a problem hiding this comment.
I think we should not force a theme to specify the theme on each place the theme references a template part. The core should automatically assume that the template part being referenced is from that theme.
There was a problem hiding this comment.
Yeah, definitely. This seems like an unnecessary attribute in this case.
| @@ -0,0 +1,5 @@ | |||
| <!-- wp:template-part {"slug":"header","theme":"emptytheme","tagName":"header"} /--> | |||
There was a problem hiding this comment.
The template parts are not loading on the edit-site screen but it is probably a bug with FSE.
There was a problem hiding this comment.
I think that's likely due to the Gutenberg change noted here. I loaded this up on a fresh site just now and it loads as expected.
This reverts commit add855c.
Empty Theme: Script to generate a personalized starter theme
Good catch! That's removed now. |
|
We just discussed this PR in the Block-based Themes chat this week, and decided that it makes sense to merge this PR in. It's been relatively solid the past couple weeks, and I think we hit all of the main discussion points in here. Plus, merging it will make @MaggieCabrera's theme generator easier for folks to use. 🙌 I'll go ahead and do that, and we can continue iterating in additional issues/PRs. Thanks everyone! |
There's just a little bit of boilerplate necessary to build a block-based theme today. This PR tries to collect that all in one place.
Theoretically you could use this today as a base to build a theme from, but I gathered it mostly to start identifying the remaining pieces that (hopefully) Gutenberg can start handling automatically. I'll leave some code comments below.
Some of the
add_theme_supportdeclarations and the (mostly) emptyexperimental-theme.jsonfile could technically be removed, but I kept them in for discussion purposes.cc @jorgefilipecosta and @nosolosw for your thoughts.