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

Full Site Editing: Update default templates #26941

Merged
merged 16 commits into from
Nov 24, 2020
Merged

Conversation

jameskoster
Copy link
Contributor

@jameskoster jameskoster commented Nov 12, 2020

Let's talk about the "default" templates list. Amongst other things, this list of templates will appear as options for users to add in the template navigation panel, in scenarios where they do not already exist. Here's how that looks:

Screenshot 2020-11-12 at 15 26 36

Note: Singular would be included as well, except for my theme already including that particular template.

Below are my thoughts on these templates:

Front page – front-page

Home page – home

Both the front-page and home templates are decidedly advanced as they are mutually exclusive, and rely on interaction with the given sites reading settings.

Considering the flexibility site owners now have in the block editor, I think we should encourage them to assemble their homepages as regular pages, and use a $custom template if they need unique properties for the homepage specifically. This would essentially make the process for creating a home page template the same as creating a unique template for any other page on site.

The Home template is more advanced as it relies on interaction with the given sites reading settings.

Verdict: Remove both Remove the Home template.


Singular – singular

Single post – single

I would deem both of these templates as advanced too due to their ambiguity, how they interact with each other, and with custom post types. Succinctly describing the situations in which either of these templates will resolve – particularly when both a present – is difficult to say the least.

Verdict: Remove both, but add a "Post" option which will add a single-post template.


Single page – page

Archive – archive

Search results – search

404 (not found) – 404

I think these are all fine, though I would like to explore updating some of their names / descriptions slightly.


Here's what an updated list might look like, as per this PR:

Screenshot 2020-11-18 at 09 40 37

One drawback with this approach is that the Index template will always resolve to display single entries from CPTs. The lack of support for $custom templates is also quite limiting. Still, I personally believe these trade-offs are worth it for now and lay a more robust foundation from which to add these features in the future.

@github-actions
Copy link

github-actions bot commented Nov 12, 2020

Size Change: -793 B (0%)

Total Size: 1.2 MB

Filename Size Change
build/api-fetch/index.js 3.42 kB +1 B
build/autop/index.js 2.84 kB +2 B (0%)
build/blob/index.js 664 B -1 B
build/block-directory/index.js 8.72 kB +1 B
build/block-editor/index.js 133 kB +239 B (0%)
build/block-library/index.js 148 kB +42 B (0%)
build/block-serialization-default-parser/index.js 1.87 kB -1 B
build/components/index.js 172 kB +68 B (0%)
build/compose/index.js 9.95 kB +20 B (0%)
build/core-data/index.js 14.8 kB -1 B
build/data/index.js 8.8 kB -915 B (10%) 👏
build/date/index.js 11.2 kB -2 B (0%)
build/deprecated/index.js 768 B -1 B
build/dom/index.js 4.95 kB +34 B (0%)
build/edit-navigation/index.js 11.1 kB -39 B (0%)
build/edit-post/index.js 306 kB +62 B (0%)
build/edit-post/style-rtl.css 6.46 kB +2 B (0%)
build/edit-post/style.css 6.44 kB +3 B (0%)
build/edit-site/index.js 23.6 kB +99 B (0%)
build/edit-site/style-rtl.css 3.87 kB +13 B (0%)
build/edit-site/style.css 3.87 kB +12 B (0%)
build/edit-widgets/index.js 26.3 kB -122 B (0%)
build/editor/index.js 43.3 kB -1 B
build/element/index.js 4.62 kB +2 B (0%)
build/format-library/index.js 6.86 kB +4 B (0%)
build/i18n/index.js 3.57 kB -1 B
build/keyboard-shortcuts/index.js 2.54 kB -308 B (12%) 👏
build/keycodes/index.js 1.94 kB -1 B
build/list-reusable-blocks/index.js 3.1 kB -2 B (0%)
build/media-utils/index.js 5.32 kB +2 B (0%)
build/notices/index.js 1.81 kB -1 B
build/plugins/index.js 2.56 kB -3 B (0%)
build/primitives/index.js 1.43 kB +1 B
build/redux-routine/index.js 2.84 kB -2 B (0%)
build/reusable-blocks/index.js 2.92 kB +2 B (0%)
build/rich-text/index.js 13.3 kB -4 B (0%)
build/server-side-render/index.js 2.77 kB -1 B
build/shortcode/index.js 1.69 kB +1 B
build/viewport/index.js 1.86 kB +2 B (0%)
build/warning/index.js 1.14 kB +1 B
ℹ️ View Unchanged
Filename Size Change
build/a11y/index.js 1.14 kB 0 B
build/annotations/index.js 3.8 kB 0 B
build/block-directory/style-rtl.css 943 B 0 B
build/block-directory/style.css 942 B 0 B
build/block-editor/style-rtl.css 11.3 kB 0 B
build/block-editor/style.css 11.3 kB 0 B
build/block-library/editor-rtl.css 8.96 kB 0 B
build/block-library/editor.css 8.96 kB 0 B
build/block-library/style-rtl.css 8.23 kB 0 B
build/block-library/style.css 8.23 kB 0 B
build/block-library/theme-rtl.css 792 B 0 B
build/block-library/theme.css 793 B 0 B
build/block-serialization-spec-parser/index.js 3.06 kB 0 B
build/blocks/index.js 48.1 kB 0 B
build/components/style-rtl.css 15.3 kB 0 B
build/components/style.css 15.3 kB 0 B
build/data-controls/index.js 827 B 0 B
build/dom-ready/index.js 571 B 0 B
build/edit-navigation/style-rtl.css 881 B 0 B
build/edit-navigation/style.css 885 B 0 B
build/edit-widgets/style-rtl.css 3.13 kB 0 B
build/edit-widgets/style.css 3.13 kB 0 B
build/editor/editor-styles-rtl.css 476 B 0 B
build/editor/editor-styles.css 478 B 0 B
build/editor/style-rtl.css 3.85 kB 0 B
build/editor/style.css 3.85 kB 0 B
build/escape-html/index.js 735 B 0 B
build/format-library/style-rtl.css 547 B 0 B
build/format-library/style.css 548 B 0 B
build/hooks/index.js 2.27 kB 0 B
build/html-entities/index.js 623 B 0 B
build/is-shallow-equal/index.js 698 B 0 B
build/list-reusable-blocks/style-rtl.css 476 B 0 B
build/list-reusable-blocks/style.css 476 B 0 B
build/nux/index.js 3.42 kB 0 B
build/nux/style-rtl.css 671 B 0 B
build/nux/style.css 668 B 0 B
build/priority-queue/index.js 790 B 0 B
build/token-list/index.js 1.27 kB 0 B
build/url/index.js 4.05 kB 0 B
build/wordcount/index.js 1.22 kB 0 B

compressed-size-action

@jameskoster jameskoster added the [Type] Discussion For issues that are high-level and not yet ready to implement. label Nov 13, 2020
@jameskoster
Copy link
Contributor Author

jameskoster commented Nov 13, 2020

Another consideration – if we decide to enable the addition of a single-post template (rather than single or singular), should we do similar with archives? IE enable the addition of separate archive-post, category, tag, author, date templates rather than the generic archive.

The pros/cons of the latter are the same as the former – clarity around template purpose vs the trade-off of falling back to index for CPTs that do not have associated templates. Arguably one additional trade-off of this approach is the volume of templates, but that is something we can likely address with a more refined UI.

TLDR: Should

Archive
Resolves when archives like categories are requested

become

Post list
Resolves when a list of posts are requested

Post list (category)
Resolves when the contents of a post category are requested

Post list (tag)
Resolves when the contents of a post tag are requested

Post list (author)
Resolves when posts by an author are requested

Post list (date)
Resolves when a posts from a specific date are requested

@kjellr
Copy link
Contributor

kjellr commented Nov 13, 2020

In general I do think your suggestions here make sense. I like the simplified options — they'll make a lot more sense to most users.

Considering the flexibility site owners now have in the block editor, I think we should encourage them to assemble their homepages as regular pages, and use a $custom template if they need unique properties for the homepage specifically. This would essentially make the process for creating a home page template the same as creating a unique template for any other page on site.

I do have a little hesitation around removing a "Homepage" from these options — mostly because it's incredibly common for users to want a standalone homepage template. They'll still be able to create one with your updates here, but it's much less obvious.

Also, (I haven't been following along super-closely, so forgive me if this is covered elsewhere, but) will there be a sort of "advanced" option available for folks who do want to create the more obscure template types?

@jffng
Copy link
Contributor

jffng commented Nov 13, 2020

I like the simplified list.

I'm waffling around removing the home page template also. I like the idea of having it in the default list of templates if we could guarantee it would be used for the home page, but as you say it requires the site reading settings to be configured accordingly.

@MaggieCabrera
Copy link
Contributor

I agree with @kjellr here. And if we went with removing the homepage from thelist, maybe a link or a hint to where the advanced templates will live would be interesting to have

@jameskoster
Copy link
Contributor Author

jameskoster commented Nov 13, 2020

mostly because it's incredibly common for users to want a standalone homepage template

I would love to unpack this a bit. A unique home page I understand, but I'd be curious to hear more about the sort of things folks generally add to their home page templates though, and establish if it is actually a template we need. My suspicion is that the affordances provided by the block editor itself (when editing content) will be adequate for the vast majority of use cases, and $custom templates (which we need to enable as well) will cover everything else. I am likely missing something though!

Also, (I haven't been following along super-closely, so forgive me if this is covered elsewhere, but) will there be a sort of "advanced" option available for folks who do want to create the more obscure template types?

Absolutely, but this is still TBD. Perhaps having the home and front-page templates available there would be adequate 🤔

@scruffian
Copy link
Contributor

I agree that having a home page template seem redundant; because there is now so much power in the block editor user's shouldn't need a separate template for the home page most of the time.

@kjellr
Copy link
Contributor

kjellr commented Nov 13, 2020

I agree that having a home page template seem redundant; because there is now so much power in the block editor user's shouldn't need a separate template for the home page most of the time.

Yeah, I see that. I'm probably not reacting to the proposal here so much as I am to the idea of how wonderful it is to see something clear called a "Homepage" listed in the full-site editor.

WordPress has historically been fairly obtuse about how you create and edit a homepage so the idea that clicking "Homepage" would result in a pre-configured, ready-to-edit homepage seems great. But that's not exactly what's being proposed here.

@jameskoster
Copy link
Contributor Author

WordPress has historically been fairly obtuse about how you create and edit a homepage so the idea that clicking "Homepage" would result in a pre-configured, ready-to-edit homepage seems great. But that's not exactly what's being proposed here.

Here's an idea: we might offer a single "Homepage" option in the add template menu, but create different templates based on the situation at hand.

If the site has a static front page we create either front-page or a $custom template and immediately apply it to the appropriate page.

If the site is displaying "latest posts" on the homepage we create the home template.

The problem with this is that if the user ever changes the homepage display setting, their homepage template no longer behaves as expected.

@kjellr
Copy link
Contributor

kjellr commented Nov 13, 2020

The problem with this is that if the user ever changes the homepage display setting, their homepage template no longer behaves as expected.

Yeah, that gets to the root of the problem. Would we mark it as "Home (Unused)" or something? And display a notice when they edit it?

I do worry this is just a bandaid over the whole weird homepage setup. 😄

@jameskoster
Copy link
Contributor Author

I do worry this is just a bandaid over the whole weird homepage setup. 😄

Exactly. It's similar in many ways to the single/singular problem. These templates are simply hard to understand.

I've been round this circle many times and always come back to the idea of placing them slightly out of reach, and putting the more intuitive templates at peoples fingertips.

@carlomanf
Copy link

front-page is always used for the front page regardless of reading settings, so what's the issue? Am I missing something here?

@jameskoster
Copy link
Contributor Author

D'oh, you're absolutely right @carlomanf. This simplifies the template somewhat, probably to the point that it is safe to include it in this menu.

what's the issue?

The other templates highlighted in the OP are still worth discussing, as is the language in the descriptions.

@carlomanf
Copy link

what's the issue?

The other templates highlighted in the OP are still worth discussing, as is the language in the descriptions.

Yes, go right ahead with that, I was just referring to all the angst about front-page. :D

@Copons
Copy link
Contributor

Copons commented Nov 23, 2020

No objections code-wise! ✨

I have a couple of questions regarding the whole flow, though:

  • These details are not just used for the "new template" dropdown.
    They are also used to default information for theme-provided templates.
    E.g. 2021 Blocks contains a single template. If we remove the single definition here, it would show up in the sidebar (and anywhere else in the dashboard) as a mysteryous "single" template, instead of having a user-friendly title and description.
    Also, the list is filterable, so third-parties can freely add or remove elements.
    With this in mind, I wonder if we should keep this list as complete as possible, and hand-pick (in the JS side) which templates to show in the "new template" dropdown. 🤔

  • I'd probably keep index as first item.
    Typically, FSE themes will provide it by themselves, so it rarely if ever will show up in the dropdown. But in the off-chance the user manages to "remove" it somehow (I can think of one way: set it as draft), I'd want it to be the easiest to add back. 😄

@Addison-Stavlo
Copy link
Contributor

Addison-Stavlo commented Nov 23, 2020

I don't have much objection to changing what we choose to show in the 'add template' dropdown, but would definitely change how we are doing so.

I wonder if we should keep this list as complete as possible, and hand-pick (in the JS side) which templates to show in the "new template" dropdown.

💯 - I don't see any reason to remove definitions from the dictionary when we can choose to only show a subset of them for any place they end up being used on the front-end. Instead of removing items here, we should just add a filter on the js side that limits what is shown in the 'add templates' dropdown. That way when we want to update this to add/remove other items in the future it will be super easy and we won't have to touch the underlying definitions. Keeping this list full enables developers to use it in many different ways, as well as allow us to more easily create something like @kjellr mentioned:

a sort of "advanced" option available for folks who do want to create the more obscure template types?

@jameskoster
Copy link
Contributor Author

@Copons @Addison-Stavlo Thanks for the clarification. I agree with you both. Should this be done in a separate issue / PR? The filtering part for the add template menu is beyond me :D

@Copons
Copy link
Contributor

Copons commented Nov 23, 2020

@Copons @Addison-Stavlo Thanks for the clarification. I agree with you both. Should this be done in a separate issue / PR? The filtering part for the add template menu is beyond me :D

Yes, let's do that separately!

The next steps could be:

  1. Take a note of which templates (and in which order) should show up in the "new template" dropdown. We'll take care of opening a PR for that.
  2. Update this PR by only keeping the copy changes. This is possibly annoying, so maybe opening another PR from scratch would save you some time. Whatever works best for you! 🙂

@jameskoster
Copy link
Contributor Author

New issue for the new-template-menu opened here: #27227

I'll update the copy here :)

@jameskoster
Copy link
Contributor Author

Copy updated. If you can re-review I'd appreciate that @Copons :)

I removed the "Default" prefixes as they lose clarity as you add more templates. I think this specificity is better communicated the other way around. IE

  • Index
  • Post
  • Post (Hello World!)

Seems more intuitive than

  • Default (Index)
  • Default Post
  • Post (Hello World!)

Copy link
Contributor

@Copons Copons left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!
I don't have any strong opinions on the copy for this.
I'm not sure "resolves" is the most user-friendly word (it sounds technical to me), but I don't have any great alternatives ("applied"?).
It's not a blocker though!

@jameskoster I've also took the liberty of updating the PR to fix some tabs turned into spaces.

@jameskoster
Copy link
Contributor Author

Thank you, sir!

Yeah the wording is hard. For now I have pushed an update that uses the same language as https://codex.wordpress.org/Theme_Development#Template_Files. It's still not perfect, but we can refine it over time.

Need to make that popover a bit wider to accomodate the slightly longer descriptions how :D

@jameskoster
Copy link
Contributor Author

Need to make that popover a bit wider to accomodate the slightly longer descriptions how :D

Added that to this PR. If it's not appropriate I can revert. Let me know @Copons :)

@Copons
Copy link
Contributor

Copons commented Nov 24, 2020

@jameskoster looking good!
I've pushed a minor fix to avoid the larger dropdown getting stuck repositioning on small screens.
I think we can merge after the checks clear! ✨

@jameskoster jameskoster merged commit e13857d into master Nov 24, 2020
@jameskoster jameskoster deleted the update/default-templates branch November 24, 2020 13:45
@github-actions github-actions bot added this to the Gutenberg 9.5 milestone Nov 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Discussion For issues that are high-level and not yet ready to implement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants