Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Block Themes] Consider an FSE-compatible approach to starter content #35680

Open
kjellr opened this issue Oct 15, 2021 · 1 comment
Open

[Block Themes] Consider an FSE-compatible approach to starter content #35680

kjellr opened this issue Oct 15, 2021 · 1 comment

Comments

@kjellr
Copy link
Contributor

@kjellr kjellr commented Oct 15, 2021

The legacy way of providing starter content for themes relied on users visiting the customizer after a fresh install:

Starter content is applied and displayed upon entering the customizer, with no changes appearing on the live site until customizer changes are explicitly saved and published.

Gutenberg currently hides the Customizer, so that's not possible for block themes. For Twenty Twenty-Two (WordPress/twentytwentytwo#116), I'd like to at least have us set a static homepage on a fresh install of the theme, but there's no FSE-based way of making that happen.

How can we make that happen? And beyond that, the previous way of entering starter content relied on a bunch of post markup sitting inside of PHP. Is there a way we can improve that now that we're working with HTML templates?

@noisysocks
Copy link
Member

@noisysocks noisysocks commented Oct 18, 2021

Thinking about this... it's a tricky problem, excuse the rough notes! 😅

This is how starter content works currently:

  • If the fresh_site option is set then we import a bunch of fake posts, widgets, menus into the current Customizer changeset on after_theme_setup.
  • This appears in the Customizer because the Customizer will use the current URL to determine which templates to render. For example if the URL being customised is / then the page with slug home will appear.
  • Modifying the database in any way (e.g. publishing a post) will unset the fresh_site option.

But full site editing is different:

  • There are no changesets. What you see in the Site Editor is the published content that comes back via the REST API.
    • We do, however, have local changes made to WordPress entities that exist in memory (@wordpress/data).
  • Users pick a template or template part to edit. It's not automatic. You can, for example, edit the index or page-home template but the Site Editor won't choose one for you based on the URL being /.
  • There's no real need for fake widgets and menus, just fake posts and perhaps template parts (e.g. to fake a navigation).

Perhaps we can set up a system where the theme can define a set of fake entities that the block editor loads into @wordpress/data after initialisation. I'm not sure how to have the Site Editor display the home page by default, though.

I'm also not sure if it will be confusing that starter content looks exactly like real content except for that it disappears when you make a change and doesn't appear in the site's frontend. I suppose we already have this problem. Still, this is a good opportunity to figure out if there is a better way to solve the problem that starter content solves.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants