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

Templates: Retain custom templates when switching themes #31954

Open
Tracked by #39324
annezazu opened this issue May 18, 2021 · 7 comments · May be fixed by WordPress/wordpress-develop#2179 or #67125
Open
Tracked by #39324

Templates: Retain custom templates when switching themes #31954

annezazu opened this issue May 18, 2021 · 7 comments · May be fixed by WordPress/wordpress-develop#2179 or #67125
Labels
[Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") [Feature] Template Editing Mode Related to the template editor available in the Block Editor [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Type] Enhancement A suggestion for improvement.

Comments

@annezazu
Copy link
Contributor

What problem does this address?

This is part of feedback from WP Tavern's coverage of the sixth call for testing with the FSE Outreach program:

From a user viewpoint, I feel like my custom-created templates belong to me rather than the theme. I can see a user switching themes after a couple of years and building a dozen or so templates having a poor experience in this situation.

Currently, if you create custom block templates and switch to another theme (even if it's block based), these custom templates are lost.

What is your proposed solution?

The approach can likely happen in a few ways or in combination:
a) make it clearer when creating templates that they are theme dependent
b) offer a way for people to migrate their templates to new themes (no clue on technical feasibility)
c) make it clear when switching themes what will be lost

@annezazu annezazu added [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Feature] Full Site Editing [Feature] Template Editing Mode Related to the template editor available in the Block Editor labels May 18, 2021
@carlomanf
Copy link

Thanks for opening the issue Anne. I have been trying to find a solution to this for many months, but the incorrect assumption was made that this is a low priority due to it being the enhancement of a "new" feature.

This is not actually true. The block-based nature may be new, but the ability for users to customise parts of their theme is nothing new. It has long been available through widget areas and menus, albeit not in a block-based way.

Widget areas and menus already have a mechanism whereby users can retrieve their customisations (i.e. widget areas and menus) from deactivated themes and apply them to a new theme. I explained this at #31397.

Given that they can already do this with widget areas and menus, users should expect nothing less than to be able to do it with block-based templates and template parts as well.

However, the current implementation of templates and template parts is incredibly poorly designed and makes it near impossible for the new theming system to mirror what the old one is quite easily capable of.

Please see my new patch at #31971 that implements a cleaner approach based on theme mods, to mirror the same approach that widget areas and menus have successfully been using for years. The patch, plus a simple addition to the UI, can easily solve this issue.

@jameskoster
Copy link
Contributor

User preferences when switching block themes are likely to be highly subjective. Some folks will expect all customisations to be retained, others will want a totally fresh start. Some will probably want granular per-customisation control.

I opened #25071 last year to discuss the switching UX, but didn't get any responses yet 😭

these custom templates are lost.

Maybe it's always been this way, but I see that custom templates do remain in Appearance > Templates after a theme switch, but they do not resolve on the frontend 🤔 I suppose this is related to the slug and is what @carlomanf's PR would address.

@carlomanf
Copy link

I opened #25071 last year to discuss the switching UX, but didn't get any responses yet 😭

That's disappointing, especially because I believe the behaviour has changed since you opened it. At the time, user templates did persist after a theme switch, but now they don't.

I agree with you that neither of these blanket solutions are ideal, and it would be better to give the user some kind of discretion. Still, the lack of responses is somewhat understandable, because the underlying infrastructures both then and now are built in such an inflexible way that they make it near impossible to create such an experience anyway.

That is what my patch changes. Rather than locking everyone in to one particular behaviour, it would provide the underlying foundation to be able to implement the kind of theme switching experience that #25071 talks about.

@annezazu
Copy link
Contributor Author

I wanted to document some thoughts from @youknowriad in slack for posterity around 5.8:

I wanted to detail the reasoning more here. The block templates are not necessarily theme specific, they can easily translate to other themes but theme CSS design can have impact and alter the result. In the future, we do want to allow them to be theme-agnostic but for the initial release we wanted to keep them theme specific because otherwise, there’s a lot of UX/UI work that need to happen on theme switching and elsewhere to take into account these new possibilities. It’s also a decision based on the initial version of FSE themes we want to ship. FSE themes rely on these templates as well (wp_template) and we don’t want to solve the cross-themes templates in the first release but we want to start exploring this at their own pace. Keeping the template editor theme specific allow us to simplify the mental model of these templates: These are just editable “Page Templates” (the custom page templates themes provide).

@richtabor
Copy link
Member

richtabor commented Jul 20, 2021

I'm also of the opinion that custom block templates should be retained. If a template is the standard theme's default template, then sure — it should change to whatever the theme decides. But otherwise, if I've created and set a specific template for a specific page, then that should be retained.

I get that the UX may be a bit more daunting, but having templates that you've created with theme X installed be rendered useless when changing themes, seems off to me.

User flow:

I create a blank.html template that only renders the post content block (just like BlockBase). I've assigned it to display on a particular page, as I want no headers or footers — just my block content for this landing page. I change my theme to get a new look cause I feel like it, but now my landing page has a header, footer and an empty sidebar next to it.

To resolve this today, I need to create a blank custom template and assign it to the page once again. If I ever change my theme, I end up with the same issue, needed to create the blank template again (while deleting the old one).

Next steps:

While we can't assume that every time I change a theme, all my custom templates should stay, I do lean in the direction that that behavior should be the default experience.

Maybe we have a mechanism that let's me opt to resetting all templates as the theme's default templates, instead of what happens today where everything resets when a theme is changed.

In addition, I should also be able to use any template I've created on any theme. I'm not sure what the purpose behind locking templates to themes is, but its seems counter-intuitive.

Related to #25071.

@annezazu
Copy link
Contributor Author

annezazu commented Oct 5, 2021

Just wanted to follow up to note that there was consensus from the folks who participated in the block theme switching exploration around wanting to be able to keep custom templates while switching themes. You can read more specific feedback here but this continues to be advocated for: https://make.wordpress.org/test/2021/10/05/fse-program-block-theme-switching-summary/

@carlomanf
Copy link

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

@annezazu annezazu added [Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") and removed [Feature] Full Site Editing labels Jul 24, 2023
@jordesign jordesign added the [Type] Enhancement A suggestion for improvement. label Sep 8, 2023
@jordesign jordesign changed the title Feedback on custom templates and switching themes Templates: Retain custom templates when switching themes Sep 8, 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] Template Editing Mode Related to the template editor available in the Block Editor [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Type] Enhancement A suggestion for improvement.
Projects
None yet
5 participants