WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.32k stars 4.12k forks source link

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

Open afercia opened 10 months ago

afercia commented 10 months ago

Description

Similar to https://github.com/WordPress/gutenberg/issues/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:

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

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 commented 10 months ago

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 commented 10 months ago

@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 commented 10 months ago

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 commented 10 months ago

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 commented 10 months ago

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 commented 10 months ago

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 commented 10 months ago

Would be the enhanced pagination issue solved with this PR?

https://github.com/WordPress/gutenberg/pull/55446

afercia commented 10 months ago

https://github.com/WordPress/gutenberg/pull/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 commented 10 months ago

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 commented 10 months ago

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 commented 1 month ago

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.