Opened 4 years ago
Closed 3 years ago
#52314 closed defect (bug) (fixed)
the HTML <title> tag for Edit Post should include the post's title
Reported by: | skierpage | Owned by: | joedolson |
---|---|---|---|
Milestone: | 5.9 | Priority: | normal |
Severity: | minor | Version: | 5.6 |
Component: | Editor | Keywords: | has-patch has-screenshots commit |
Focuses: | accessibility, administration | Cc: |
Description
- Open wp-admin > Posts > All Posts
- Hover over a post then click Edit
RESULT:
The web page's <title>
tag is just "Edit Post โน your blog name โ WordPress". There is no indication of what page you are editing. This makes it harder to later locate the tab in the browser, makes bookmarking posts you regularly edit harder, and the other problems of a poor web page title.
EXPECTED RESULT:
It would be nice to see part of the post's title in the web page's <title>
, e.g. "Edit Post 'Britney Spearsโฆ evar' โน your blog name โ WordPress"
VERSION: 5.6 in Firefox Nightly, running Linux on server and browser, using Gutenberg plug-in 9.7.0.
(This could be a bug in the Gutenberg editor rather than WordPress; there's code in src/wp-admin/edit.php
to set the title:
$title = $post_type_object->labels->name;
but I'm not sure what it does.)
Attachments (10)
Change History (44)
#3
in reply to:
โย 2
@
4 years ago
Replying to alexstine:
Thanks so much for responding and for the PHP code!
The title should ideally be less than 64 characters in length.
With a 14-character blog name, that still leaves 22 characters for the post title in "Edit Post 'Britney Spears greatesโฆ' โน your blog name โ WordPress", excluding ellipsis. (My initial example truncated the middle of the post title, which is cool but probably overkill.) Also note the <title>
of this Trac web page: it's 92 characters and includes the bug description because it's the right thing to do despite the W3C style guideline ๐.
#4
@
4 years ago
+1 to this issue: I hate to think how much time I've spent trying to find the correct "Edit post" tab over the years.
For what it's worth, my quick thought is that the following <title> format would be best for most people:
Edit: [Post name] < [Blog name] โ WordPress
I think we want as many words of the title as possible to be visible in the browser tab. Given that, including the post type (e.g. "Edit post:") does not seem above the bar.
For very long post names, it might make sense to truncate a bit. But I agree with @skierpageโit seems fine to exceed the W3C 64 character recommendation in this case.
#5
@
4 years ago
- Focuses accessibility added
Seems like the status quo is especially bad for editors who rely on screen readersโit could slow them down a bunch.
This ticket was mentioned in โSlack in #accessibility by ryokuhi. โView the logs.
4 years ago
#7
@
4 years ago
After discussion in the Accessibility team bug scrub, we're going to consider this a bug. While the current title can be argued to meet the requirements of WCAG 2.4.2 (โhttps://www.w3.org/WAI/WCAG21/Understanding/page-titled), by conveying the purpose of the page, it does not provide enough distinction to differentiate between multiple windows when those windows may be editing different posts.
It's a relatively minor issue, as it only impacts users working on multiple documents at once, but still an issue.
Noting that a final solution should probably include JS to monitor and react when the post title is changed in the editor.
#8
@
4 years ago
- Milestone changed from Awaiting Review to 5.8
- Owner set to alexstine
- Status changed from new to accepted
This ticket was mentioned in โSlack in #accessibility by ryokuhi. โView the logs.
3 years ago
This ticket was mentioned in โSlack in #core by lukecarbis. โView the logs.
3 years ago
#14
follow-up:
โย 31
@
3 years ago
- Keywords has-screenshots added
The title should ideally be less than 64 characters in length.
Maybe I'm wrong but I think this "rule" is only relevant for search engine optimization. If so, I think we don't really care about the length of the title of an admin page, isn't it? ๐
#15
@
3 years ago
I just added patch: https://core.trac.wordpress.org/attachment/ticket/52314/52314-2.diff
In this patch, I changed the "Untitled" text to read "Add POST_TYPE_HERE". E.g. for a page it will read "Add Page".
Maybe this would look better than just "Edit Untitled" until we implement dynamic title updates via JS?
Thanks.
This ticket was mentioned in โSlack in #accessibility by joedolson. โView the logs.
3 years ago
@
3 years ago
alternate option: keep existing Add New Post title, create the new Edit title when post is already published (even if untitled)
#18
@
3 years ago
I think 'Edit "Untitled"' is appropriate when a post is published without a title, so I made an additional option 52314-alternate.diffโ.
- If adding a new post, the title tag maintains the pre-existing "Add New Post" text.
- If the post is already published, the new HTML title matches the aria-label for each Edit link that leads to the post editor.
- If a published post does not have a title when the post editor loads, 'Edit "Untitled"' calls more attention to the missing title (without a formal error message).
However, if you disagree with me, 52314-3.patch simply includes some changes for translation: translating the "Untitled" string, plus matching the new Edit title to the aria-label text.
#19
@
3 years ago
I think 'untitled' is better, probably. In addition to the reasons @sabernhardt called out, it maintains contextual parity with how the title attribute is used when there is a title - the references are equivalent.
I will note that we can have both - there's no reason we can't use 'Edit {post_type} "Untitled"'.
In that case, I'd argue we should re-use the existing 'edit_item' string and append the post title. I don't think there's a translation issue here, since the 'edit_item' string is totally independent from the post title.
Thoughts?
#20
@
3 years ago
I'm unsure whether including the post type would help with a screen reader, though keeping the page title short would be better in the case of seeing multiple tabs (comment:4). (If we want to add the type, I don't know how to use the edit_item
label.)
The post type was already included in the current, non-unique title. So the latest patch checks to verify the post title is not empty before replacing that version with Edit ""
(in themes other than Twenty Twenty-One).
If a theme or plugin filters the title with a placeholder name, the new title tag uses that. With โTwenty Twenty-One's post title filter, a post published without entering a title would have Edit "Untitled"
because "Untitled" is the main heading of the front-end page then.
#21
@
3 years ago
- Keywords needs-testing removed
The last proposal looks good to me. Are we fine with using that one for 5.8 @joedolson @sabernhardt? Or should it wait for the next release? I'm fine either way, but I think we're good to go as it :)
#22
@
3 years ago
@alexstine and Joe would have more valuable opinions than mine, but I'm content with my most recent patch 52314-4.diffโ :)
#23
@
3 years ago
I feel like we're losing the post type context if we shift to just the post title. It's certainly possible a user could be editing multiple posts with the same title but of different types, and it would be nice to be able to convey that in the title.
I think it benefits all users equally.
As far as the title length goes and how it's represented in the browser, screen reader users will have the full title read if they choose to hear it, as they aren't constrained to the visible text; other users will get what they get. In common cases, like pages or posts, it won't be that many additional characters.
In my personal browser use, it wouldn't make a difference either way...all I'm going to see is 'Edi'. :D
The edit item string is part of the post type label array: See: โhttps://developer.wordpress.org/reference/functions/get_post_type_labels/
#24
@
3 years ago
- Milestone changed from 5.8 to 5.9
Today is 5.8 Beta 1. As discussions are ongoing, punting to 5.9.
#25
@
3 years ago
At this point, how can we move this ticket forward? Still trying to decide on a patch or is it awaiting further testing? I personally do not have a preference. Whatever works the best, I'm good with.
Think we'll be able to land this for 5.9 and then get Gutenberg Issue open for dynamic JS updates?
#26
@
3 years ago
The ticket was waiting on another option, so I tried the edit_item
label in 52314-5.diffโ.
I like the simplicity of the previous patch, but now we have both methods to decide between them.
#27
@
3 years ago
I just tested 52314-5.diff and am happy with this patch. Think we can get this committed for 5.9 or is it already too late in the game?
I think it addresses all points. I get Edit Post/Edit Page followed by the title. Also, works for Add New Post/Add New Page. This should work fine for custom post types since this now uses labels.
Thanks.
#28
@
3 years ago
- Keywords commit added
The patch looks good to me as well in my tests. Marking for commit
#31
in reply to:
โย 14
@
3 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
Replying to audrasjb:
The title should ideally be less than 64 characters in length.
Maybe I'm wrong but I think this "rule" is only relevant for search engine optimization. If so, I think we don't really care about the length of the title of an admin page, isn't it? ๐
I would suggest reconsidering this. The <title>
tag on pretty much any other admin screen follows this format:
[screen title] โน [site title] โ WordPress
so it seems a bit inconsistent not to do the same on this screen. Titles can be longer than 64 characters, so we're not strictly following that recommendation anyway, and might as well keep using the same format for consistency.
See 52314.6.diffโ.
@skierpage Thanks for submitting a ticket.
I am not 100% for sure, but I'd say the reason why this isn't included in core is because of the recommended length for the "title" tag. Please see here.
โhttps://www.w3.org/Provider/Style/TITLE.html
That being said, you are not out of options. There is a core filter called "admin_title" and you can use it to adjust this for the post screen.
โhttps://developer.wordpress.org/reference/hooks/admin_title/
Here's a small snippet that I wrote on my test site. Do not use this in production until testing to make sure it works well for you. It will generate a title that looks like this.
This should work well across pages and posts. I tested using Classic Editor and Gutenberg.
add_filter( 'admin_title', 'change_admin_title_posts_screen', 10, 2 ); function change_admin_title_posts_screen( $admin_title, $title ) { global $post, $pagenow; if ( isset( $pagenow ) && 'post.php' == $pagenow ) { // Make sure we only change title on post.php $new_title = sprintf( __( '%1$s: %2$s ‹ %3$s — WordPress' ), $title, // Edit Post $post->post_title, // Post title get_bloginfo( 'name' ) // Blog title ); return $new_title; // Return new title } else { return $admin_title; // Sanity line to return default title } }
That is using the custom filter, you can add that snippet in a custom mu-plugin, plugin, or โchild theme for testing.
I'd say if anything, this is likely an "Enhancement", not a "Bug." I could not replicate any difference between Classic Editor and Gutenberg in 5.6. Maybe others have an opinion on this?
Hope it helps. Thanks.