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

Remove coupling of templates, parts, and patterns when switching themes #25071

Open
Tracked by #39324
jameskoster opened this issue Sep 4, 2020 · 5 comments · May be fixed by WordPress/wordpress-develop#2179 or #67125
Open
Tracked by #39324
Labels
[Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. Needs Design Needs design efforts. [Type] Task Issues or PRs that have been broken down into an individual action to take

Comments

@jameskoster
Copy link
Contributor

I believe the way templates/template parts are handled upon theme-switch may warrant some exploration. For the purpose of this conversation let's assume you are using block themes exclusively.

Currently when you activate a new theme, any of the old theme templates that you have customised are retained. In general I think this behaviour is good as it reduces the unexpected disruption to layout that can occur upon theme activation. But "in general" ≠ "always" :)

Imagine you made some very minor template edits to your post content template part in the past. Now imagine you found a new theme with a post layout you really like. With the current implementation, when you activate the new theme, your posts will continue to render using the old themes post layout, undermining the whole purpose for switching themes in the first place. To get the desired experience you'd have to manually go and delete/revert your old template customisations - an activity that is totally detached from theme activation.

Let's talk about whether users should be presented with options for what should be done with their customisations when they activate a new theme. At the very least, it seems prudent to ask them whether they want to keep their customised templates. But is there a case to be made for unedited templates being kept as well? Maybe their motivation for switching themes is based more on style than layout.

There is potential for any decisions made here to be extended to Global Style customisations as well.

@aristath aristath added [Feature] Full Site Editing [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Type] Discussion For issues that are high-level and not yet ready to implement. labels Sep 4, 2020
@carlomanf
Copy link

Let's talk about whether users should be presented with options for what should be done with their customisations when they activate a new theme. At the very least, it seems prudent to ask them whether they want to keep their customised templates. But is there a case to be made for unedited templates being kept as well?

There is a precedent here with widgets and menus, where you can create them in one theme and then bring them to another theme after switching. The difference between this and what you describe, is it happens after the theme switch, rather than upon the theme switch. In other words, there is a short window of time where the new theme might look "unfinished" because the user hasn't yet moved their old widgets and menus into place.

#31971 would provide the underlying foundation for the same process to be possible with customised templates and template parts, provided a UI is built for it. That said, I guess the preview mode of the customiser was meant to stop the "unfinished" version of a new theme from being publicly visible, so this might be seen as a regression.

In terms of keeping unedited templates, I think that could only be done through some equivalent to the customiser's preview mode, because I'm of the opinion that a theme's files should not be accessed when it's inactive. It seems a breach of trust, and could be a security risk, especially on multisite. That would mean that the user's decision to keep an unedited template can only be made before the theme switch is completed, not after.

Although, this could cause confusion for the user about being allowed to bring over customised templates and template parts whenever they like, but for unedited ones they only get one chance.

@mtias
Copy link
Member

mtias commented May 24, 2021

There's a few things we need to do here. The biggest new introductions we have are user templates and user global styles; these both open new possibilities and bring new challenges. First we should outline user flows that we anticipate or want to make possible. For example:

  • Choosing a theme and wanting to switch everything to the new look (discard any user modifications in templates or styles).
  • Wanting to preserve some customizations such as colors or header navigation. Or conversely; wanting to replace styles and navigation but leave everything else intact.
  • Wanting to preserve everything (essentially incorporating a new theme's templates or patterns on demand).
  • There could be themes with different set of templates (say, a commerce theme that brings in new templates) that are additive.

Some of these problems should be approached from a block perspective since there's a lot we can do on the navigation block itself to accommodate some flows.

What is clear is that we can no longer assume for users what they may want to do but we should choose a good default. It'd be reasonable to make the first option the default since it's what most are accustomed to, but we can discuss it. Semantic template parts are also a tool we have for managing some expectations since they can overlap between themes.

Theme switching should have the option of being a more granular operation in the site editor, walking users through some steps where they could choose to retain or discard specific templates (like a header) or global styles. Right now there's a lack of clarity upon switching themes about whether a specific part of the site will be replaced or not.

@carlomanf
Copy link

I opened another patch to aid with a solution to this, if anyone would like to test: WordPress/wordpress-develop#2179

@mtias mtias mentioned this issue Jan 26, 2022
57 tasks
@mtias mtias changed the title Template handling on block-theme switching Remove coupling of templates and parts when switching themes Feb 4, 2022
@mtias mtias added [Type] Task Issues or PRs that have been broken down into an individual action to take and removed [Type] Discussion For issues that are high-level and not yet ready to implement. labels Feb 4, 2022
@adamziel adamziel moved this to Tracking issues in WordPress 6.0 Editor Tasks Mar 17, 2022
@jameskoster jameskoster moved this to Needs design in 6.3 Design Mar 30, 2023
@jameskoster jameskoster added the Needs Design Needs design efforts. label Mar 30, 2023
@annezazu annezazu moved this to 🎨 Needs design in Gutenberg Phase 2: Customization May 9, 2023
@annezazu
Copy link
Contributor

With four weeks until beta 1, removing this from the 6.4 board as we haven't made enough progress to reasonably ship something to solve this complex problem.

@annezazu
Copy link
Contributor

While this issue remains open, I wanted to share a video about the impact it has today where I switch from using Twenty Twenty-Three where I've edited the blog home template to Twenty Twenty-Four where all of that content is removed:

losing.homepage.content.when.switching.themes.mov

Because that content is in the prior template of Twenty Twenty-Three and not in a page, I'm not able to recover what's there after switching and have to switch back. In the past, when switching between themes, this didn't happen as you either displayed latest posts or had a set page assigned to the homepage. This is part of the conundrum of this issue at hand and, with live previewing available with block themes, we should consider how best to surface those things there.

@annezazu annezazu changed the title Remove coupling of templates and parts when switching themes Remove coupling of templates, parts, and patterns when switching themes Oct 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. Needs Design Needs design efforts. [Type] Task Issues or PRs that have been broken down into an individual action to take
Projects
Status: 🎨 Needs design
Archived in project
5 participants