Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
What's the best approach for using the rel=next/prev meta tags in Views pages to indicate the next & previous pagination links? Are more tokens necessary to make this combination work?
Comment | File | Size | Author |
---|---|---|---|
#6 | nextprev_links_metatag_compat.patch | 1.2 KB | Jehu |
Comments
Comment #1
tr-drupal CreditAttribution: tr-drupal commentedNot sure if this topic is meant for such replies, so I will just post :) Please delete it, if it's there for a different purpose.
I was looking for solutions in the last few days and mostly this one being referred: http://pivica.me/blog/how-create-drupal-pagination-use-rel-next-and-rel-...
I'm not really into Drupal development, so no idea what to do with that, but maybe it helps.
Also some ideas and a sandbox-module here:
https://www.drupal.org/node/1567684
https://www.drupal.org/sandbox/nlisgo/2361421
Not sure where if fits best in: metatags or views... Would say metatags as the first thought...
Comment #2
Dieter Geiling CreditAttribution: Dieter Geiling commentedHI - Can anyone confirm that the rel=next/prev metatags works with views? If yes, wich token are the right one for that?
It seems that the module Clean Pagination which also do that is broken if metatag is installed :/
It would be cool to have a working solution for rel=next/prev with metatag.
Any idears?
Greetings
Comment #3
DamienMcKenna@Dieter: The problem with Clear Pagination is as described in #2509246: Meta tags from other modules removed even if no values provided by Metatag, so we'll focus on fixing that bug there instead of in this issue.
Comment #4
sebumd CreditAttribution: sebumd commentedI used the following module on github out of the box: https://github.com/nlisgo/nextprev_links but changed the drupal_add_html_head_link to the following drupal_add_html_head so that metatag doesn't intercept the metatags.
drupal_add_html_head(array(
'#tag' => 'link',
'#attributes' => array(
'href' => $head_link['href'],
'rel' => 'next',
),
), 'pager_next_link');
Comment #5
vaccinemedia CreditAttribution: vaccinemedia at CTI Digital commented@Dieter did you ever find out what the correct tokens are? The documentation is sparse / non existent and this has become a requirement from a client. I already have the metatag module installed and can see the next / prev options but don't know what tokens should be put in or if they need to be put in on the view or in the general mitigate settings.....
Comment #6
Jehu CreditAttribution: Jehu commentedbased on @sebumd's hint i've patched the prevnext_links module from github. Patch file attached.
See pull request.
Comment #7
nlisgo CreditAttribution: nlisgo commentedIf you are having issues with the nextprev_links module working with metatags module please head over to the following issue to add clear recreate steps and to test a possible fix when I post it up later:
#2613216: Module doesn't work with metatags module enabled
Comment #8
criscomYou can do this with the metatags module easily.
Just go to the Canonical URL and Shortlink URL fields and put in something like:
[current-page:url:absolute]?page=[current-page:page-number]
As a result on page two of the paged view content you get :
<link rel="canonical" href="https://www.mysite.com/views-pager/title?page=2">
Comment #9
criscomAdjustment to my solution in #8: You'd better use
[site:current-page:url]
in order to get the url pattern and link rel="canoncial" right.Comment #10
sittard CreditAttribution: sittard commentedThis works brilliant for pages with a pager but my issue with this approach is that it adds ?page=0 to the canonical URL of all pages without a pager as well.
Comment #11
elukacs CreditAttribution: elukacs as a volunteer commentedThere is the pager_tokens module and it works well with Metatag.
It provides the previous and next page url tokens: