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

Query loop: Non-inherited queries must also update the document title (potential impact on SEO) #55489

Open
afercia opened this issue Oct 19, 2023 · 11 comments
Labels
[Block] Query Loop Affects the Query Loop Block [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Type] Bug An existing feature does not function as intended

Comments

@afercia
Copy link
Contributor

afercia commented Oct 19, 2023

Description

Similar to #51579

When implementing an 'in page' navigation à la 'single page app', a few things must always be implemented. Amongst them, a routing mechanism, integration with the browser history API, and announcing navigation occurred to assistive technology.

One more fundamental aspect is that the document title must be updated.
If it isn't updated:

  • All entries in the browser history will have the same name.
    • This makes the browser history UI unusable, since there is no way for users to distinguish which page is which.
    • Edge caseL It makes pointless adding pagination pages to the bookmarks as all the saved bookmark will have the same name.
    • It impacts SEO as the paginated pages will be indexed but they have the same document title.

The 'classic' pagiination always adds 'page 2', 'page 3', etc. to the document title:

classic pagination

The 'Enhanced' pagination does not:

enhanced pagination

Step-by-step reproduction instructions

  • Go to the wp Dashboard > Settings > Reading settings
  • Set 'Blog pages show at most' to 5, just to have more paginated pages
  • View the fron end and to to an archive page, e.g. an yearly archive. I tested with: http://localhost:8889/2012/
  • Go back and forth the pagianted pages a few times.
  • Observe the document title changes adding the page number.
  • Click and hold the browser Back or Forward buttons.
  • Observe each entry can be easily distinguished because of the page number.
  • Checl also the Full history page of your browser.
  • Edit the archive template in use in the editor.
  • Select the Query loop block and enable 'Enhanced pagination'.
  • Repeat the steps above.
  • Observe all the entries in the history have the same name.

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

@afercia afercia added [Type] Bug An existing feature does not function as intended [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Block] Query Loop Affects the Query Loop Block labels Oct 19, 2023
@afercia
Copy link
Contributor Author

afercia commented Oct 20, 2023

Worth also mentioning that a Query Loop block with 'Enhanced pagination' can be added also to a normal post or page.

In this case, the post or page actually become an archive page with paginated pages. Still, the document title will not change and will always be the same across all paginated pages.

Tje URL will change, e.g.:

https://my-site.org/my-awesome-post/?query-1-page=1
https://my-site.org/my-awesome-post/?query-1-page=2
https://my-site.org/my-awesome-post/?query-1-page=3

The document title will stay the same for all paginated pages, e.g.:

<title>My awesome post – My site</title>

@fabiankaegy
Copy link
Member

@afercia I think your last comment conflates two things. It has always been the case that the pagination added on a post / page that uses the query param based pagination doesn't update the page title.

So I think there are two issues here. One is a long standing one that you are now finding, and the other is a new introduction with 6.4 and the enhanced pagination.

The new issue is that enhanced pagination on archive templates where you use the inherit option doesn't update the document title.

@afercia
Copy link
Contributor Author

afercia commented Oct 20, 2023

It has always been the case that the pagination added on a post / page that uses the query param based pagination doesn't update the page title.

@fabiankaegy yes that is possible but I would say it's an edge case. Worth improving it though.

The main issue here is about the archive pages. With SEO impact still to fully evaluate.

@afercia
Copy link
Contributor Author

afercia commented Oct 20, 2023

It has always been the case that the pagination added on a post / page that uses the query param based pagination doesn't update the page title.

I see a substantial difference between the situation with classic themes and block-based themes though.

Before:
adding some archive-like pagination to post / page and attempt to uses the query param based pagination was essentially a task for theme plugin developers. As developers, they had the technical skills to take care of the document title, if they wanted.

Now:
Users can and a Query Loop block and the Pagination block everywhere. As such, WordPress should make sure that it works correctly everywhere, updating the document title when necessary.

@fabiankaegy
Copy link
Member

I see a substantial difference between the situation with classic themes and block-based themes though.

Before: adding some archive-like pagination to post / page and attempt to uses the query param based pagination was essentially a task for theme plugin developers. As developers, they had the technical skills to take care of the document title, if they wanted.

Now: Users can and a Query Loop block and the Pagination block everywhere. As such, WordPress should make sure that it works correctly everywhere, updating the document title when necessary.

I don't think I understand where you are drawing the line here. Regardless of whether you are in a block theme or in a classic theme that uses the block editor. You can insert a query block on any post / page in either. Which always has the query parameter based pagination which doesn't update the title.

So the issue is the same for all kinds of themes. This issue is fundamental to the Query block.

And the addition of "enhanced pagination" doesn't change anything about that.

The only difference with block based themes is that you can now also use the query block on archive pages and therefore use that actual /page/ based pagination. Before adding the "enhanced pagination" feature this did update the title correct. But now with the enhanced pagination the title is not updated correctly when the inherit option is selected.

@afercia
Copy link
Contributor Author

afercia commented Oct 23, 2023

I don't think I understand where you are drawing the line here.

When I mentioned 'classic' themes and block-based themes, I meant 'classic' as in: the traditional themes where pagination is managed by WordPres stemplating functions and users can't mess with the Query Loop.

Before adding the "enhanced pagination" feature this did update the title correct. But now with the enhanced pagination the title is not updated correctly when the inherit option is selected.

I think it doesn't update correctly also wjen inherit is disabled annd a custom query runs. Regardless, 'enhanced pagination' breaks a native browsers feature. Or, better, it males it unusable which is something that seems less than ideal to me.

As I mentioned, there's also potential SEO concerns here still to be fully evaluated.

@cbravobernal
Copy link
Contributor

Would be the enhanced pagination issue solved with this PR?

#55446

@afercia
Copy link
Contributor Author

afercia commented Oct 25, 2023

#55446 solves the accessibility and usability issue.
I'm not sure it fully solves the potential SEO issue. I'd like to hear thoughts from some SEO experts here.

@cbravobernal
Copy link
Contributor

I'm not a SEO expert, but I guess when robots access different pages, they do a navigation per page, instead of clicking on the different pagination links. In that case all pages have their own urls and can be crawled, so should not be a problem.

@afercia
Copy link
Contributor Author

afercia commented Oct 26, 2023

I'm not an SEO expert so I'm not going to make assumptions about things I'm not 100% familiar with.
Just noting that it's not only about crawling, It's also about the Search results.

Anyways, it is important to take into consideration WordPress core has a few filters in place in the code that generates the document title. With Enhanced pagination enabled, these filters will keep returning the value generated via PHP on first page load as expected, but the value will not change when clicking the Enhanced pagination links. Basically these filters won't work and there's no equivalent implementation with Enhanced pagination enabled.
Plugins do use these filters to handle the title, description, opengraph tags and schemas. Also, the lack of the pagination related query_var(s) does have an impact and I'm not sure it has been fully evaluated.

Right now, while the document title is updated with the page number, other tags generated by plugins don't get the correct page number as they expect the WP filters to just work.

I'd think that at the very least the WordPress 6.4 Field Guid should put this problem in big relevance.
Ideally, an equivalent JS implementation to the core filters should have been provided.

Screenshot 2023-10-26 at 14 49 55

Cc @enricobattocchi

@luisherranz luisherranz changed the title Query loop: Enhanced pagination must also update the document title (potential impact on SEO) Query loop: Non-inherited queries must also update the document title (potential impact on SEO) Jul 26, 2024
@luisherranz
Copy link
Member

I have renamed the title since the problem with enhanced pagination was solved in this pull request, and only the issue with non-inherited queries remains, which does not update the title even with enhanced pagination disabled.

Moreover, if non-inherited queries modify the page title someday, it will work by default with enhanced pagination because that's just updating the title with whatever is inside the <title> tag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Query Loop Affects the Query Loop Block [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

4 participants