WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.57k stars 4.22k forks source link

Allow templates to be applied to multiple items #50415

Open tomxygen opened 1 year ago

tomxygen commented 1 year ago

Currently, when creating a new template (page, article, etc), you have the option to choose between applying it to all items or to a specific item. However, it's not clear that if I choose to apply it to a specific item, then I can't reuse it later for other items, because it doesn't appear in the template selection when writing a new article/page. To achieve this, one needs to create a custom template, which isn't very convenient since you start building from scratch and you don't have a pre-made template.

My proposed solution to this issue is changing the option from Specific item to Specific Items. I've also created a mockup in Figma to show the difference between the current implementation and my proposal.

Screenshot 2023-05-02 at 3 20 37 PM Screenshot 2023-05-02 at 2 49 30 PM

When choosing "for specific items", you can then select which items to apply the template to. And then, when the template is published, it's also possible to apply it, when writing a new or article or page, in the template selection.

I believe this change will make the template creation process more user-friendly and improve the overall user experience.

Cc: jameskoster

carolinan commented 1 year ago

That would mean that every template that is not the default for the post type is a generic custom template. So the option to select one could also just be removed.

That is how the template hierarchy works:

tomxygen commented 1 year ago

Hey @carolinan, thanks for your reply.

every template that is not the default for the post type is a generic custom template. So the option to select one could also just be removed

I understand your concert and in fact @jameskoster replied to me in #50134 suggesting three options:

  1. For all posts
  2. For a specific post
  3. To be used by any post ad hoc (with better wording of course).

Currently, if I want to apply a specific post template to some of my posts, I need to build a custom template, and this is not user friendly as it requires me to build a custom template that has to be designed from scratch, instead of relying a pre-made template that I can be build upon. Also, speaking from an ease-of-use perspective, especially those who don't really know how the site editor works yet, in order to build a template for a post they would click on "Single item: post" and not "custom template", which sounds more complicated and not suited for the user's intent since they're just building a post template and a post option is already there.

I can give you a real life scenario where my proposal would make sense: Imagine you have a blog where you post movie reviews and book reviews. The two kind of reviews are very similar but do have some differences. Currently you have to build two custom templates, every time designing the article from scratch. Imagine just being able to select a post template, edit it, rename it and then apply it to all the movie/book reviews. Another example is imagine you have a woocommerce store where you sell products in three different categories of the same niche. Maybe you would want to create three different product pages, which look very similar but maybe have a few differences like the background color based on the category of the product. Instead of having to select a custom template and designing it from scratch, you could just select the Product template and start designing from that. And a great addition would be to be able to simply duplicate existing templates.

tomxygen commented 1 year ago

I’d love to get a feedback from @jasmussen as well!

carolinan commented 1 year ago

I don't think that more options that does the same thing makes it easier.

It sounds to me that the solution is to allow the user to select from a premade template when they create a new custom template. As far as I know that is already implemented, using the so called pattern selector modal. So starting from a blank custom template is optional.

jasmussen commented 1 year ago

Hey, thanks for your energy on the project!

Carolina is more knowledgable than myself on the inner workings of templates in the WordPress theming system, so I defer to her. It is my understanding that a fair bit of this falls down to the WordPress template hierarchy.

I will say that I think we have an opportunity in the user interface, to increase the utility of those existing templates, and better explain what they do. For example when editing the structure of your site — your homepage, your static subpages, etc — many of the templates that exist are are conceptually related to that site structure, and very much feel like "content" pages. Search and 404 templates come to mind. Even archive, and many of the generic blog templates can be thought of as just pieces of site structure or content that can be edited together. Because all of these templates are automatically applied across your site.

Custom page templates, on the other hand, say "Blank page" or "Page with sidebar", do not necessarily fall in that category. They are not applied by default — you have to actively edit a page, then apply that particular alternative page template for it to display.

This type of template may also actually accomplish your stated use case, give or take a tweak in user experience.

I suspect many users will think of such custom templates differently from the traditional and automatically applied templates. So in my mind, it could make sense to differentiate between the two types. It needs some exploration, though.

carolinan commented 1 year ago

I think it is apparent it needs to be improved, but how? If you are not familiar with WordPress, or you are a WordPress user but not familiar with the template hierarchy, it is also not obvious why there can be only one 404 template, one search, and so on.

jasmussen commented 1 year ago

This is one concept that explores it: https://github.com/WordPress/gutenberg/issues/50418

tomxygen commented 1 year ago

@carolinan

It sounds to me that the solution is to allow the user to select from a premade template when they create a new custom template. As far as I know that is already implemented, using the so called pattern selector modal. So starting from a blank custom template is optional.

I'm not aware of this possibility. I just tried to select a custom template and the only two patterns available are post and blank.

Screenshot 2023-05-09 at 12 09 19 PM

allow the user to select from a premade template when they create a new custom template

Although this may be a possible solution, I still find it confusing. If I want to build a custom template for my posts, I click on the "+" and I get the following options:

Screenshot 2023-05-09 at 12 12 34 PM

I would click on "Single: post" because it says exactly what I'm looking for: a post! Instead, I wouldn't go for a custom template because "custom" may be something I design from scratch which isn't part of the well known templates like Pages, Posts, WooCommerce Products, etc.

@jasmussen

I suspect many users will think of such custom templates differently from the traditional and automatically applied templates.

I'm sorry, It's probably because I'm not experienced with the template hierarchy, but I'm definitely missing something. Could you please explain why my proposal couldn't work? Click on the "+" and select:

In my opinion, this would solve the confusion around the word "custom" and definitely improve the workflow.

carolinan commented 1 year ago

For option 1 C, "Custom", how would you explain to the user that it is not automatically assigned? You would have to select it from the template dropdown in the block editor.

Option 1 A (default) and B (one specific) and all templates except the "custom template" at the bottom of the list are automatic.

tomxygen commented 1 year ago

For option 1 C, "Custom", how would you explain to the user that it is not automatically assigned? You would have to select it from the template dropdown in the block editor.

I made a simple mockup in Figma to show how I would implement it, comparing it to the current implementation.

Screenshot 2023-05-09 at 6 07 50 PM Screenshot 2023-05-09 at 6 07 59 PM

And of course you're able to select the template from the template dropdown in the block editor.

Behind the scenes, option 1 and 2 are unchanged. Instead, option 3 creates what is currently called "custom template", and populates the canvas with the blocks of the chosen template (in the mockup it's a page).

all templates except the "custom template" at the bottom of the list are automatic.

I'm not sure what you mean here, could you elaborate further?

carolinan commented 1 year ago

"Selected pages" might work; I like it.

all templates except the "custom template" at the bottom of the list are automatic. I'm not sure what you mean here, could you elaborate further?

When "Add new template" is clicked, there is a modal with a list of templates. All templates are automatically assigned except the bottom one, the custom template, which is separated by a line from the rest.

jameskoster commented 1 year ago

Thank you all for working on this. My instinct is that creating templates for specific entities is not a particularly intuitive concept, compared to creating a generic template and applying it. The latter seems more long-winded, but probably makes more sense, and a good design can streamline things for sure.

One thing to consider though, is that $custom templates can only be applied to single entries. The template hierarchy would not allow the "Selected Pages" flow when creating a template for something like a post category. This seems like a bit of a shame, and would likely be confusing for end users. Is there anything we can do about this?

tomxygen commented 1 year ago

might work; I like it.

That's great! What's the next step? Any chance other people could share their feedback?

creating templates for specific entities is not a particularly intuitive

In my opinion, what is not intuitive is that if I want to create a template for some of my posts, and I go into the site editor, I click on the "+" to add a new template and I see "Single item: post" which is exactly what I'm looking for... except it's not. Yesterday I asked a few friends of mine with different levels of expertise in WordPress (but none in the site editor) to create a Post template that could be applied to some of the posts. All of them created a "Single item: post", and then were surprised that they couldn't apply it to some of the posts. They thought they could find the newly created template inside the Template selection in the Post page. And none of them could figure out how to create a reusable template for more than one (but not all) the posts. Actually, they were kind of surprised when I told them that they had to select "custom template" instead of "Single item: post", because they thought that "custom template" means something that is not included in the well know wordpress templates.

The template hierarchy would not allow the "Selected Pages" flow

Why wouldn't it allow it? Is it a technical limitation? Once the template is created, when I'm writing a post I can select a custom template from the template selection in the Post page, so why wouldn't it be possible to assign the template to different posts, when creating the template? Instead of assigning the template Post by Post, I would assign it all at once before creating it. And then of course, I'd be able to assign it to more Posts in the post page.

anything we can do about this?

If my proposal of selecting pages isn't actually achievable, one possible solution would be to create a "Single item: Page/Post/Product etc", and tell the user that they can select it in the Page/Post/Product creation page, like this:

Screenshot 2023-05-09 at 6 07 50 PM Screenshot 2023-05-10 at 5 17 34 PM
carolinan commented 1 year ago

Posts, pages and categories are not handled the same way. A custom template works for post types. So if you have pages A and B, they can use a custom template. But tag "kitten" and category "books" can not. they can only use the template that matches their name exactly.

tomxygen commented 1 year ago

Okay so the modal window that allows selecting the "Selected" template should appear only for Pages and Posts, not for tags and categories. Right? Isn't this enough to fix the issue with tags and categories that can't use custom templates?

jameskoster commented 1 year ago

My point was that it could be confusing if you can perform this "Selected pages" flow when creating templates for posts/pages, but not when creating templates for categories, tags, etc? But it may not be a big deal.

The bigger question is whether it's something we want to consider enabling in the future. Expanding the template hierarchy has come up before. But I suppose that should be discussed elsewhere. Apologies for the detour :)

What's the next step? Any chance other people could share their feedback?

I think we should consider this as a part of the work in https://github.com/WordPress/gutenberg/issues/50395.

tomxygen commented 1 year ago

think we should consider this as a part of the work in https://github.com/WordPress/gutenberg/issues/50395.

Should I comment in #50395 summarizing what we've discussed here?

jameskoster commented 1 year ago

Perhaps a short note to highlight the related issue. It may end up being something that we action separately but the breadrcrumb trail can be useful.