#62053 closed enhancement (fixed)
Warn logged in users when rendering empty template in the front end
Reported by: | vcanales | Owned by: | mikachan |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | |
Component: | Editor | Keywords: | has-patch |
Focuses: | template | Cc: |
Description
Proposes adding a warning for logged-in users when navigating to a page or post rendered through an empty template. The warning explains why the website's visitors might encounter a blank page and points the logged-in user to the Site Editor to fix the template by resetting it or adding content to it.
Discussion: https://github.com/WordPress/gutenberg/issues/64027
Proposed UI:
Attachments (1)
Change History (15)
This ticket was mentioned in PR #7354 on WordPress/wordpress-develop by @vcanales.
3 months ago
#1
#2
@
2 months ago
I added a comment to the related issue suggesting two things:
- A slightly different wording:
"This page is blank because your theme's template is currently empty. It may have been accidentally deleted, but don't worry!You can easily reset or edit this template in the site editor."
- A link to our documentation: https://wordpress.org/documentation/article/site-editor/
@mrfoxtalbot commented on PR #7354:
2 months ago
#3
Thank you for working on this @vcanales, I added a comment with two minor suggestions https://github.com/WordPress/gutenberg/issues/64027#issuecomment-2385791997
@mrfoxtalbot commented on PR #7354:
2 months ago
#4
Can I ask you, @cbravobernal, or maybe @getdave to review this?
I'd love for this change to make it to the 6.7 in time.
Thanks a bunch.
#5
@
2 months ago
Thanks @vcanales! Also pinging @peterwilsoncc and @kirasong here as the 6.7 Core Tech Leads 🙇
#6
@
2 months ago
While testing, I noticed that the editor falls back to the version of templates included in the theme if they are emptied in the site editor.
In the screen shot above, the left window is viewing the home page (after emptying it) while logged in and the right window is while logged out.
I like the idea for templates that aren't in the theme but for templates that are, it would be good to show what the logged out users see.
To reproduce the screen shot:
- Activate 2025
- Open the site editor
- Edit the blog home page
- Switch to the code editor
- Delete all markup and save
- View the site while logged in
- View the site using a private/incognito window
I did confirm the warning only shows if the template is empty, it doesn't show for empty template-parts. So the code is a good starting point.
I'll leave some notes on the PR too for code related issues.
#7
@
4 weeks ago
Thanks for all the feedback here and on the PR, @peterwilsoncc.
With your testing steps above, I'm seeing something slightly different. I see a blank page on the front end when logged out, which also matches the Editor. And then the front end logged in shows the new warning message:
Is this the expected behaviour? I'm happy to pick this up and help progress if I can. I went ahead and merged the latest trunk into the PR, in case there are any other changes that may affect how this is working.
#8
@
4 weeks ago
@mikachan Did you empty the template in the code editor or by deleting the blocks via the UI? It's possible the template was clear of blocks but had some white space causing the white screen.
I noticed that if I delete all the code, I get the default while logged out. But if I make the content <!-- empty but not empty -->
or even a few spaces then the template shows as a white screen for logged out users.
Maybe WP needs some smarts to figure out if a template is truly empty. Unfortunately this will be more complex.
#9
@
4 weeks ago
I used the code editor to delete the blocks, and I can't see any white space left behind. I also tried adding blocks back in (just a paragraph block), saving, and then deleting this via the code editor again, and I still see a blank template when logged out.
Just to clarify what I'm seeing in the code editor:
In any case, I like the idea of defaulting to the theme's template when the user is logged out, so I've gone ahead and committed a change to the PR that hopefully does this. To test (following your steps above):
- Activate 2025
- Open the site editor
- Edit the blog home page
- Switch to the code editor
- Delete all markup and save
- View the site while logged in: It should show the new, "This page is blank because the template might have been deleted..." warning message.
- View the site using a private/incognito window: If the template is included with the theme (like Blog Home), then it should default to the contents from the theme. If the template is not included with the theme, e.g. a custom template, it should show a blank template.
I've also applied a wording change from @mrfoxtalbot in this commit.
@mikachan commented on PR #7354:
3 weeks ago
#10
Thanks for all the feedback, @richtabor 🙇 I think I've addressed all your comments, this is ready for another review.
@get_dave commented on PR #7354:
12 days ago
#11
@mikachan Let me know when you are ready to commit this and we can pair on commit to WP Core.
@get_dave commented on PR #7354:
10 days ago
#12
@mikachan This now needs a commit. A good opportunity for you. LMK if you want to run through this.
#13
@
10 days ago
- Owner set to mikachan
- Resolution set to fixed
- Status changed from new to closed
In 59449:
@mikachan commented on PR #7354:
10 days ago
#14
Committed to Core in core.trac.wordpress.org/changeset/59449.
Proposes adding a warning for logged-in users when navigating to a page or post rendered through an empty template. The warning explains why the website's visitors might encounter a blank page and points the logged-in user to the Site Editor to fix the template by resetting it or adding content to it.
Related issue: https://github.com/WordPress/gutenberg/issues/64027
Trac ticket: https://core.trac.wordpress.org/ticket/62053