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?

CommentFileSizeAuthor
#6 nextprev_links_metatag_compat.patch1.2 KBJehu
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tr-drupal’s picture

Not 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...

Dieter Geiling’s picture

HI - 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

DamienMcKenna’s picture

@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.

sebumd’s picture

I 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');

vaccinemedia’s picture

@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.....

Jehu’s picture

based on @sebumd's hint i've patched the prevnext_links module from github. Patch file attached.

See pull request.

nlisgo’s picture

If 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

criscom’s picture

You 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">

criscom’s picture

Adjustment 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.

sittard’s picture

This 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.

elukacs’s picture

There is the pager_tokens module and it works well with Metatag.
It provides the previous and next page url tokens:

[current-page:url:with-previous-page-number]
[current-page:url:with-next-page-number]