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

Post title: if a name isn't set in the creation process, the page title isn't visible in the editor #67539

Closed
annezazu opened this issue Dec 3, 2024 · 19 comments · Fixed by #67673
Assignees
Labels
[Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@annezazu
Copy link
Contributor

annezazu commented Dec 3, 2024

Titling this for the Post Title block since it's the same as for the Page Title. Using Gutenberg nightly (Version 19.9.20241203) with WP 6.7.1 and TT5, I found that if I don't name a page when creating one, a post title block is not rendered in the template for me to then edit:

no.page.title.without.naming.page.mov

Replication steps

  1. Open Appearance > Editor
  2. Head to Pages
  3. Add a new page and don't give it a title
  4. Notice there's no post title block to edit and name the page.
@annezazu annezazu added [Block] Post Title Affects the Post Title Block [Type] Bug An existing feature does not function as intended [Feature] DataViews Work surrounding upgrading and evolving views in the site editor and beyond labels Dec 3, 2024
@carolinan
Copy link
Contributor

isn't this expected though? I believe not having the title is something that many users are asking for.

@t-hamano
Copy link
Contributor

t-hamano commented Dec 4, 2024

This looks like a bug to me.

In Twenty Twenty-Five or Twenty Twenty-Four, there is a template called "Page No Title". When you create a new page without a title, somehow this template is automatically applied:

Image

I think creating a page with an empty title is generally when we haven't decided a title yet, and doesn't mean applying a page template that has no title.

@benazeer-ben
Copy link
Contributor

benazeer-ben commented Dec 4, 2024

Hi everyone,

There is an option in the edit section to rename the page. Using this, you can add the desired name to the page.

I believe this option can be helpful in such scenarios where the template chosen is 'Page No Title'.

Please find the attached video for reference.

Screenshare.-.2024-12-04.11_27_20.AM.mp4

@t-hamano
Copy link
Contributor

t-hamano commented Dec 4, 2024

I found another problem. When creating a page in the site editor, enter the title no-title. In TT5 and TT4, the "Page No Title" template is applied. On the other hand, in TT3, a default Page template is applied:

cb177f19a0fe0203f300c6a941e4e648.mp4

The problem here is that the template applied by default changes depending on the type of template the theme has, or the title when creating a page.

Here is the process to create a post, but I don't understand why this behavior occurs.

cc @youknowriad @ramonjd @scruffian

@t-hamano t-hamano added [Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") and removed [Block] Post Title Affects the Post Title Block [Feature] DataViews Work surrounding upgrading and evolving views in the site editor and beyond labels Dec 4, 2024
@carolinan
Copy link
Contributor

carolinan commented Dec 4, 2024

If you have a page with the slug "apple" and a custom page template named page-apple, that template will be used
https://developer.wordpress.org/themes/basics/template-hierarchy/#single-page

The default in WordPress for pages that has no title is not "No title" but "Untitled". My guess is Gutenberg may be using this wrong?

@t-hamano
Copy link
Contributor

t-hamano commented Dec 4, 2024

If you have a page with the slug "apple" and a custom page template named page-apple, that template will be used

I see, thanks for letting me know. So does that mean that what's reported in this issue is actually the correct behavior?

@carolinan
Copy link
Contributor

carolinan commented Dec 4, 2024

If users are finding it unexpected, then it is not the correct behavior, even if WP is mapping the template and page slug correctly.

@t-hamano
Copy link
Contributor

t-hamano commented Dec 4, 2024

After further investigation, it seems that the classic editor applies the default template regardless of the title or slug, so the behavior in Gutenberg seems odd:

83d10410a17f80787fca70d11bc34b87.mp4

@carolinan
Copy link
Contributor

Is the slug no-title? I think the slug is page_id=142?

I did not know that the classic editor even understood HTML templates, they do not have the page header that the PHP templates do.

@carolinan
Copy link
Contributor

I was able to find some more time to test this. My suggestion would be to try to always create a unique slug when there is no title, because there could be many more themes with these types of page templates.

@annezazu
Copy link
Contributor Author

annezazu commented Dec 4, 2024

Thank you all for digging in here! Just to recap, I don't see this as expected behavior when comparing it to the original add new page flow. I don't always want to title things when getting started and I don't think I'm alone there. I'd expect it would use the default template, unless I manually changed it, as I think it's a big leap for one to expect that not including a title would fully change a set template.

@ramonjd
Copy link
Member

ramonjd commented Dec 4, 2024

The problem here is that the template applied by default changes depending on the type of template the theme has, or the title when creating a page.

As @carolinan mentions, this has been the default behaviour in Core since 4.7.

If Gutenberg wanted to override this, there are filters in get_query_template that could work.

When you create a new page without a title, somehow this template is automatically applied:

Yeah. It's a bit inconsistent though, as if you create a second page with no title, it uses the default template. 🤔

Updating the default title text (Currently 'No title') doesn't seem robust as there's the possibility of matching with anything you put there.

Maybe we could override default behaviour when creating new pages like this?

@t-hamano
Copy link
Contributor

t-hamano commented Dec 5, 2024

Let me summarize what I understand from this isue.

  • I think the issue here is with custom templates, not the theme templates that are automatically determined based on the template hierarchy (page.{html|php}, page-{slug}.{htmlphp|}).
  • A theme can have custom templates. In a classic theme, we define Template Name: as metadata. In a block theme, we define it in the customTemplates field of theme.json.
  • Twenty Twenty-Four and Twenty Twenty-Five define a custom template called "Page No Title".
  • When you create a new post with an empty or no-title title via the block editor or site editor, the "Page No Title" custom template is automatically applied in Twenty Twenty-Four and Twenty Twenty-Five.
  • This behavior does not occur in the classic editor.

Are these correct?

@carolinan
Copy link
Contributor

carolinan commented Dec 5, 2024

page-{slug} is what is being used for "Page no title".

So when the second untitled page is created its slug is no-title-2: This no longer match page-no-title. To do that, the template would need to be page-no-title-2.

All the customTemplates field in theme.json seem to do is add the readable name. Without it, the templates still exist, but the name is not "pretty", it shows with the slug (I have not tested this for a while).

I still think that, when the page is created, the editor should just avoid using a generic slug and use the post id if the user does not enter a title. What is shown to the user in the title fields can still be a readable label.

@carolinan
Copy link
Contributor

carolinan commented Dec 5, 2024

And in cases when it is not untitled, but match an existing template, perhaps help the user with a notice?
If the page slug is apple and the page template is page-apple, perhaps tell the user what is happening?
"A matching page template was found, you can change the template in (instructions..)"

Plugins may still rely on this working as it has done, historically.

@youknowriad
Copy link
Contributor

I think this auto-matching based on slug behavior is very arguable to be honest, that said, I think we should at least disable it entirely for pages/posts with "empty titles". So my question is why "pages without title" are being assigned the no-title slug. I believe they should be assigned some very random/internal temporary slug instead of no-title which can be a good slug to assign to a page.

@ramonjd
Copy link
Member

ramonjd commented Dec 6, 2024

I think we could safely delete this line:

It will fallback to the default behaviour we see in the post editor, and generate a unique slug using wp_unique_post_slug - usually a page with no title will be assigned $post_id . $suffix here

What do folks think?

@t-hamano
Copy link
Contributor

t-hamano commented Dec 6, 2024

I think we could safely delete this line:

I think so too 👍

@ramonjd
Copy link
Member

ramonjd commented Dec 6, 2024

I'll throw a PR up.

@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Dec 6, 2024
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") [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants