[5.x] - Change canonical links for paginated pages#1301
Open
JimmyHoenderdaal wants to merge 11 commits into
Open
[5.x] - Change canonical links for paginated pages#1301JimmyHoenderdaal wants to merge 11 commits into
JimmyHoenderdaal wants to merge 11 commits into
Conversation
Jade-GG
requested changes
Jun 2, 2026
Jade-GG
reviewed
Jun 10, 2026
Jade-GG
previously approved these changes
Jun 10, 2026
royduin
reviewed
Jun 30, 2026
royduin
reviewed
Jul 22, 2026
| $pageUrl = fn (int $page) => $page > 0 ? $url . '?' . http_build_query(['page' => $page]) : $url; | ||
| @endphp | ||
|
|
||
| @section('canonical', $pageUrl($currentPageIndex)) |
Member
There was a problem hiding this comment.
I thought the idea with this was to have the next/prev meta links? With this we only get the current url with the page query param.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Some explanation here:
On product overview pages we have pagination to navigate to pages. In the past we used a
<button>tag here instead of an<a>tag. Google prefers<a>withhref. This can help Googlebot (the Google web crawler) find subsequent pages.We already fixed that here.
Next thing Google prefers:
We already do this, so we don't need to change anything here — we can always go back to page 1 from every page. See the screenshot below.
Then the last part for pagination: Use URLs correctly
Give each page a unique URL. For example, include a
?page=nquery parameter, as URLs in a paginated sequence are treated as separate pages by Google.We already do this — when we navigate to the next page, you'll see
?page=2in the URL.Don't use the first page of a paginated sequence as the canonical page. Instead, give each page its own canonical URL.
This is what we haven't done yet. When we visit the Rapidez demo and use the pagination, the canonical stays the same:
<link rel="canonical" href="https://demo.rapidez.io/men.html">. This should instead be different for every page. So what we've added now is that every page has its own canonical, like this:<link rel="canonical" href="http://rapidez.test/men/tops-men.html?page=3" />.Also added in this pull request:
<link rel="next" href="{{ $pageUrl($currentPageIndex + 1) }}" />. In the past Google used this, but it isn't needed anymore so I removed it in this commitSee also for more info: https://developers.google.com/search/docs/specialty/ecommerce/pagination-and-incremental-page-loading