Skip to content

Site Title: prevent from saving and rendering a value made of only spaces #60467

Open

Description

Description

Empty links are far from ideal for SEO and accessibility.

Turns out that:

  • The classic admin doesn't allow to save a Site Title value made of only paces.
  • The editor Site Title block does.

So that there is an inconsistency in the way the site title value is first of all saved to the database.
This inconsistency may lead to rendering an empty link on the front end.

Step-by-step reproduction instructions

  • Use a theme that has the Site Title block on one of its templates e.g. Twenty Twent-Four > Blog Home template.
  • Go to the classic admin General Settings > Site Title
  • Empty the site title value and save.
  • In a new browser tab, go to the front end home page.
  • Observe the site title is not rendered.
  • Switch to the browser tab with the classic admin General Settings page.
  • Enter two spaces in the site title input field and save.
  • After the page refresn, observe the site title input field does not contain spaces. It's empty, which proves classic WordPress doesn't allow to save a value of only spaces.
  • Keep this tab open, and open a new tab to go to the Site Editor.
  • Select the Site Title block, enter two spaces and save.
  • Switch to the browser tab with the classic admin General Settings page and refresh the page.
  • Observe the site title input field now does contain two spaces.
  • In a new browser tab, go to the front end home page.
  • Observe the Site Title block is now rendered but the link contains two spaces. This is an empty link, far from ideal for SEO and accessibility and should be avoided. Example of the rendered markup:
<p class="wp-block-site-title">
    <a href="http://localhost:8889" target="_self" rel="home" aria-current="page">   </a>
</p>
  • Switch to the browser tab with the classic admin General Settings page.
  • Don't do any edit and save.
  • After the page refreshes, observ ethe two spaces in the site titel input field have been removed.
  • Go to the front end and observe the empty site title is not rendered any longer.
  • Observe the block render callback does check whether a site title value is set, but it doesn't trim it.

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    [Block] Site TitleAffects the Site Title Block[Focus] Accessibility (a11y)Changes that impact accessibility and need corresponding review (e.g. markup changes).[Package] Block library/packages/block-library[Type] BugAn existing feature does not function as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions